************************
*** 2021 CES RECODES ***
************************

use "${here}2021 Canadian Election Study v2.0.dta", clear

***********************
*** GENDER IDENTITY ***
***********************

** CHECK ORIGINAL VARIABLE
tab cps21_genderid

** GENERATE NEW VARIABLE THAT ONLY INCLUDES CLOSE-ENDED RESPONSES
gen genderid = cps21_genderid if cps21_genderid < 4

** GENERATE GENDER LABELS AND APPLY THEM TO GENDER IDENTITY VARIABLE
label define genders 1 "Man" 2 "Woman" 3 "Non-Binary" 4 "Hostile/Non-Cooperative Responses"
label values genderid genders
label variable genderid "Gender Identity (Three-Category)"

** LIST OPEN-ENDED RESPONSES
list cps21_genderid_4_TEXT if cps21_genderid_4_TEXT ~= "-99"

** CODE OPEN-ENDED RESPONSES INTO GENDER IDENTITY VARIABLE
gen genderid_open = upper(cps21_genderid_4_TEXT) if cps21_genderid_4_TEXT ~= "-99"
list genderid_open if genderid_open ~= ""

replace genderid = 1 if regexm(genderid_open, "MALE")
replace genderid = 1 if regexm(genderid_open, "MAN")
replace genderid = 1 if regexm(genderid_open, "MASCULIN")
replace genderid = 2 if regexm(genderid_open, "FEMALE")
replace genderid = 2 if regexm(genderid_open, "WOMAN")
replace genderid = 2 if regexm(genderid_open, "FEMME")
replace genderid = 2 if regexm(genderid_open, "FEMNE")
replace genderid = 2 if regexm(genderid_open, "FEMME QUEER")
replace genderid = 3 if regexm(genderid_open, "AGENDER")
replace genderid = 3 if regexm(genderid_open, "GENDER APATHETIC")
replace genderid = 3 if regexm(genderid_open, "TWO-SPIRITED")
replace genderid = 3 if regexm(genderid_open, "TWO SPIRITED")
replace genderid = 3 if regexm(genderid_open, "BI-GENDER")
replace genderid = 3 if regexm(genderid_open, "AUCUN")
replace genderid = 3 if regexm(genderid_open, "GENDER-QUEER")
replace genderid = 3 if regexm(genderid_open, "GENDERFLUID")
replace genderid = 3 if regexm(genderid_open, "IDK")
replace genderid = . if regexm(genderid_open, "HUMAN")
replace genderid = 2 if regexm(genderid_open, "FEMALE")

** REMAINING CATEGORIES ARE HOSTILE OR NON-COOPERATIVE RESPONSES
list genderid_open if genderid == .
replace genderid = 4 if genderid == .
tab genderid if genderid_open ~= ""
list genderid_open if genderid_open ~= "" & genderid == 1
list genderid_open if genderid_open ~= "" & genderid == 2
list genderid_open if genderid_open ~= "" & genderid == 3
list genderid_open if genderid_open ~= "" & genderid == 4

****************************
*** TRANSGENDER IDENTITY ***
****************************

** CHECK ORIGINAL VARIABLE
tab cps21_trans

** RECODE TRANS IDENTITY VARIABLE SO CISGENDER COMES FIRST
gen trans = 0 if cps21_trans == 2
replace trans = 1 if cps21_trans == 1
replace trans = 2 if cps21_trans == 3

** LABEL TRANS IDENTITY VARAIBLE
label define gendermodality 0 "Not Transgender" 1 "Transgender" 2 "Don't Know"
label values trans gendermodality
label variable trans "Transgender Identity (or Gender Modality)"

***************************
*** TWO-SPIRIT IDENTITY ***
***************************

tab cps21_two_spirit

** GENERATE 
gen two_spirit = .
replace two_spirit = 0 if cps21_two_spirit == 2
replace two_spirit = 1 if cps21_two_spirit == 1
replace two_spirit = 2 if cps21_two_spirit == 3

label define twospirit 0 "Not Two-Spirit" 1 "Two-Spirit" 2 "Don't Know"
label values two_spirit twospirit
label variable two_spirit "Two-Spirit Identity"

**************************************
*** COMPARISON GROUPS FOR 2021 CES ***
**************************************

** NON-BINARY ONLY
gen enby = 0 if genderid ~= 3
replace enby = 1 if genderid == 3

label variable enby "Non-Binary Only Comparison Group"

** NON-BINARY + BINARY TRANS VARIABLE
gen trans_enby = 0 if genderid ~= 3 & trans ~= 1
replace trans_enby = 1 if genderid == 3 | trans == 1

label variable trans_enby "Non-Binary and Binary Trans Comparison Group"

** NON-BINARY + BINARY TRANS + TWO-SPIRIT
gen trans_enby_2S = 0 if genderid ~= 3 & trans ~= 1 & two_spirit ~= 1
replace trans_enby_2S = 1  if genderid == 3 | trans == 1 | two_spirit == 1

label variable trans_enby_2S "Non-Binary, Binary Trans, and Two-Spirit Comparison Group"

** GENERATE BINARY VS. NON-BINARY VARIABLE
gen binary = .
replace binary = 0 if genderid == 3 & trans_enby == 1
replace binary = 1 if genderid ~= 3 & trans_enby == 1

label define bin 0 "Non-Binary" 1 "Binary Trans"
label values binary bin
label variable binary "Binary Trans Dummy (Non-Binary and Binary Trans Respondents Only)"

*list genderid trans sexuality_open if sexualid == -2

***********************
*** SEXUAL IDENTITY ***
***********************

gen sexuality_open = upper(cps21_sexuality_5_TEXT) if cps21_sexuality_5_TEXT ~= "-99"
tab sexuality_open

gen sexualid = .
replace sexualid = cps21_sexuality if cps21_sexuality < 5
replace sexualid = 5 if cps21_sexuality == 6

** GENDER IDENTITY RESPONSES TO SEXUAL IDENTITY QUESTION
replace sexualid = -2 if regexm(sexuality_open, "ANDROGYNOUS") | ///
			 regexm(sexuality_open, "ANDROGENOUS") | ///
			 regexm(sexuality_open, "BI-GENDER") | ///
			 regexm(sexuality_open, "CROSS DRESSER") | ///
			 regexm(sexuality_open, "NON-BINARY") | ///
			 regexm(sexuality_open, "TRANSGENDER")

** INATTENTIVE: NATIONAL ORIGIN
replace sexualid = -1 if regexm(sexuality_open, "AFRICAN-CANADIAN")
replace sexualid = -1 if sexuality_open == "CANADIAN"
replace sexualid = -1 if sexuality_open == "FIJIAN"
replace sexualid = -1 if regexm(sexuality_open, "KOREAN")
replace sexualid = -1 if sexuality_open == "GREEK"
replace sexualid = -1 if regexm(sexuality_open, "HONG KONGER")
replace sexualid = -1 if regexm(sexuality_open, "J’AI HONTE")
replace sexualid = -1 if regexm(sexuality_open, "NORTHERN IRISH")
replace sexualid = -1 if regexm(sexuality_open, "RACIST QUESTION")
replace sexualid = -1 if sexuality_open == "NON"

** HOSTILE/NON-COOPERATIVE
replace sexualid = 0 if regexm(sexuality_open, "HUMAN")
replace sexualid = 0 if sexuality_open == "A PERSON"
replace sexualid = 0 if sexuality_open == "ALIVE"
replace sexualid = 0 if sexuality_open == "FUNNY CLOWN"
replace sexualid = 0 if regexm(sexuality_open, "MALE")
replace sexualid = 0 if regexm(sexuality_open, "NONSEXUAL")
replace sexualid = 0 if regexm(sexuality_open, "CISGENRE")
replace sexualid = 0 if regexm(sexuality_open, "FGHHH")
replace sexualid = 0 if regexm(sexuality_open, "HIPPOPOTAMUS")
replace sexualid = 0 if regexm(sexuality_open, "HéLICOPTèRE")
replace sexualid = 0 if regexm(sexuality_open, "ASHKENAZI")
replace sexualid = 0 if regexm(sexuality_open, "AVEC HANDICAP")
replace sexualid = 0 if regexm(sexuality_open, "NORMAL")
replace sexualid = 0 if regexm(sexuality_open, "PERSON")
replace sexualid = 0 if regexm(sexuality_open, "WHY DOES THIS MATTER")
replace sexualid = 0 if sexuality_open == "ORK"
replace sexualid = 0 if sexuality_open == "UNIQUE"
replace sexualid = 0 if regexm(sexuality_open, "SHAPE SHIFTER")
replace sexualid = 0 if sexuality_open == "POLYAMORIST"
replace sexualid = 0 if regexm(sexuality_open, "SPIRITUAL BEING")

replace sexualid = 1 if regexm(sexuality_open, "STRAIGHT") | ///
			regexm(sexuality_open, "HETERO") | ///
			regexm(sexuality_open, "HETéROSEXUEL") | ///
			regexm(sexuality_open, "HOMME QUI AIME FEMME") | ///
			regexm(sexuality_open, "HéTéROSEXUEL") | ///
			regexm(sexuality_open, "ÉTéRAUSEXUELLE")
			
replace sexualid = 2 if regexm(sexuality_open, "HOMOSEXUAL") | ///
			regexm(sexuality_open, "HOMOSEXUEL") | ///
			regexm(sexuality_open, "HMOSEXUAL")

replace sexualid = 3 if regexm(sexuality_open, "BISEXUAL")

replace sexualid = 6 if regexm(sexuality_open, "PANSEXUAL") | ///
			regexm(sexuality_open, "PAN SEXUAL") | ///
			regexm(sexuality_open, "PANSEXUEL") | ///
			regexm(sexuality_open, "PAN-CURIOUS")

replace sexualid = 7 if regexm(sexuality_open, "ASEXUAL") | ///
			regexm(sexuality_open, "ACE") | /// 
			regexm(sexuality_open, "ASEXUEL") | /// 
			regexm(sexuality_open, "AUCUN") | ///
			regexm(sexuality_open, "DEMISEXUAL") | ///
			regexm(sexuality_open, "DEMISEXUEL") | ///
			regexm(sexuality_open, "DEMI SEXUEL") | ///
			sexuality_open == "ROMANTIC" | ///
			regexm(sexuality_open, "PANROMANTI")
			
replace sexualid = 8 if sexuality_open == "FLUID" | ///
			sexuality_open == "TWO SPIRITED"
			
replace sexualid = 9 if regexm(sexuality_open, "I LIKE THE WINE") | ///
			regexm(sexuality_open, "NEED TO IDENTIFY") | ///
			regexm(sexuality_open, "ANYTHING") | ///
			regexm(sexuality_open, "UNLABELLED") | ///
			regexm(sexuality_open, "SEXUAL") | ///
			regexm(sexuality_open, "LABEL IT") | ///
			regexm(sexuality_open, "IF I FIND LOVE")

tab sexuality_open if sexualid == .

replace sexualid = 0 if sexualid == . & sexuality_open ~= ""

label define sexualities -2 "Gender Minority Responses" ///
			 -1 "National Origin Responses (Inattentive)" ///
			 0 "Hostile/Non-Cooperative" ///
			 1 "Straight/Heterosexual" ///
			 2 "Gay/Lesbian" ///
			 3 "Bisexual" ///
			 4 "Queer" ///
			 5 "Questioning" ///
			 6 "Pansexual" ///
			 7 "Asexual/Demisexual" ///
			 8 "Other Non-Heterosexual Responses" ///
			 9 "No Labels"
label values sexualid sexualities

gen sexualid4 = .
replace sexualid4 = 1 if sexualid == 1
replace sexualid4 = 2 if sexualid == 2
replace sexualid4 = 3 if sexualid == 3
replace sexualid4 = 4 if sexualid > 3 & sexualid ~= .

label define sexualities2 1 "Straight/Heterosexual" ///
			  2 "Gay/Lesbian" ///
			  3 "Bisexual" ///
			  4 "Other"
label values sexualid4 sexualities2

**********************
*** LGBTQ DUMMY ***
**********************

gen lgbtq = .
replace lgbtq = 0 if genderid < 3 & ///
			trans == 0 & ///
			sexualid == 1
replace lgbtq = 0 if two_spirit == 0
			
replace lgbtq = 1 if genderid == 3 | ///
		       trans == 1 | ///
		       sexualid > 1 | ///
		       sexualid == -2 | ///
		       two_spirit == 1

****************************************
*** ADDITIONAL DEMOGRAPHIC VARAIBLES ***
*** CAMPAIGN PERIOD SURVEY *************
****************************************

***********
*** AGE ***
***********

** CHECK ORIGINAL VARIABLE
tab cps21_yob

** GENERATE MAIN AGE VARIABLE
gen age = 2021 - (cps21_yob + 1919)
label variable age "Age"

** GENERATE AGE CATEGORIES FOR COMPARISON WITH TRANS PULSE AND CENSUS
gen age_cat = 0 if age < 20
replace age_cat = 1 if age > 19 & age < 25
replace age_cat = 2 if age > 24 & age < 35
replace age_cat = 3 if age > 34 & age < 50
replace age_cat = 4 if age > 49 & age < 65
replace age_cat = 5 if age > 64

** GENERATE 4-CATEGORY AGE VARIABLE FOR REGRESSIONS
gen age4 = .
replace age4 = 1 if age > 17 & age < 30
replace age4 = 2 if age > 29 & age < 45
replace age4 = 3 if age > 44 & age < 65
replace age4 = 4 if age > 64

label define ages 1 "18-29" 2 "30-44" 3 "45-64" 4 "65+"
label values age4 ages

*****************
*** EDUCATION ***
*****************

*** EDUCATION
** EDUCATION VARIABLE FOR COMPARISON WITH TRANS PUSLE AND CENSUS
gen education = .
replace education = 1 if cps21_education < 5
replace education = 2 if cps21_education == 5
replace education = 3 if cps21_education > 5 & cps21_education < 9
replace education = 4 if cps21_education > 9 & cps21_education < 12

** EDUCATION VARIABLE FOR REGRESSION ANALYSIS
gen education4 = 0 if cps21_education < 5
replace education4 = 1 if cps21_education > 4 & cps21_education < 9
replace education4 = 2 if cps21_education == 9
replace education4 = 3 if cps21_education > 9
replace education4 = . if cps21_education == 12

gen university = .
replace university = 0 if cps21_education < 9
replace university = 1 if cps21_education > 8 & cps21_education < 12

**************
*** INCOME ***
**************

*** 8-CATEGORY INCOME
gen income = cps21_income_cat
recode income 9 = .
replace income = 2 if cps21_income_number > 0 & cps21_income_number < 30001
replace income = 3 if cps21_income_number > 30000 & cps21_income_number < 60001
replace income = 4 if cps21_income_number > 60000 & cps21_income_number < 90001
replace income = 5 if cps21_income_number > 90000 & cps21_income_number < 110001
replace income = 6 if cps21_income_number > 110000 & cps21_income_number < 150001
replace income = 7 if cps21_income_number > 150000 & cps21_income_number < 200001
replace income = 8 if cps21_income_number > 200000 & cps21_income_number ~= .

** LABEL VALUES OF INCOME
label define incomes 1 "No income" 2 "$1 to $30,000" 3 "$30,001 to $60,000" 4 "$60,001 to $90,000" 5 "$90,001 to $110,000" 6 "$110,001 to $150,000" 7 "$150,001 to $200,000" 8 "More than $200,000"
label values income incomes

** LOW INCOME
gen low_income = 0 if cps21_income_number ~= . | (cps21_income_cat ~= . & cps21_income_cat ~= 9)
replace low_income = 1 if cps21_income_number < 30000
replace low_income = 1 if cps21_income_cat < 3

************
*** RACE ***
************

gen other_race = upper(cps21_vismin_10_TEXT)

** GENERATE WHITE DUMMY
gen white = 0

*** RECODE CLOSE-ENDED RESPONSES
replace white = 1 if cps21_vismin_9 == 1

*** RECODE OPEN-ENDED RESPONSES
replace white = 1 if other_race == "CANADIAN" | other_race == "CANADIEN" | other_race == "CANADIENNE"
replace white = 1 if regexm(other_race, "BRITISH")
replace white = 1 if regexm(other_race, "EUROPEAN")
replace white = 1 if regexm(other_race, "CAUCASIAN") | regexm(other_race, "CAUCASIEN")
replace white = 1 if regexm(other_race, "SLAVIC")
replace white = 1 if regexm(other_race, "ACADIEN")
replace white = 1 if regexm(other_race, "PORTUGAIS")
replace white = 1 if regexm(other_race, "JEWISH")
replace white = 1 if regexm(other_race, "QUéBéCOIS")
replace white = 1 if regexm(other_race, "QUEBECOIS")
replace white = 1 if regexm(other_race, "ARMENIAN")
replace white = 1 if regexm(other_race, "FRANCOPHONE")
replace white = 1 if regexm(other_race, "ITALIAN")
replace white = 1 if other_race == "4TH GENERATION CANADIAN"
replace white = 1 if regexm(other_race, "I DO NOT USE THE TERM")
replace white = 1 if regexm(other_race, "CANADIAN IF ASIA IS AN AREA")
replace white = 1 if regexm(other_race, "PORTUGUESE")
replace white = 1 if regexm(other_race, "CELTIC")
replace white = 1 if regexm(other_race, "CAUCAEN")
replace white = 1 if regexm(other_race, "HUNGARIAN, SLOVAKIA")
replace white = 1 if regexm(other_race, "GREEK")
replace white = 1 if regexm(other_race, "SEPHARDIC")
replace white = 1 if regexm(other_race, "JE CROIS EUROPE")
replace white = 1 if regexm(other_race, "CAUCASION")
replace white = 1 if regexm(other_race, "FRANCO-ONTARIAN") | regexm(other_race, "FRANCO-ONTARIEN")
replace white = 1 if regexm(other_race, "ANGLO-SAXON")
replace white = 1 if regexm(other_race, "ANGLO SAXON")
replace white = 1 if regexm(other_race, "CANADIAN ONLY")
replace white = 1 if regexm(other_race, "I’M A CANADIAN.")
replace white = 1 if regexm(other_race, "SCOTTISH")
replace white = 1 if regexm(other_race, "FRENCH CANADIAN")
replace white = 1 if regexm(other_race, "I AM WHITE")
replace white = 1 if regexm(other_race, "ROMANI")
replace white = 1 if regexm(other_race, "ROMA")
replace white = 1 if regexm(other_race, "GYPSY")
replace white = 1 if regexm(other_race, "MIXED RACE, BLACK AND WHITE")
replace white = 1 if regexm(other_race, "CANADIEN FRANçAIS")
replace white = 1 if regexm(other_race, "CAUSICIAN")
replace white = 1 if regexm(other_race, "NORWEGIAN")
replace white = 1 if regexm(other_race, "IRISH")
replace white = 1 if regexm(other_race, "VIKING")
replace white = 1 if regexm(other_race, "MACEDONIAN")
replace white = 1 if regexm(other_race, "PLEASE QUIT CALLING ME WHITE")
replace white = 1 if regexm(other_race, "SAME AS ABOVE")

** RECODE MISSING
replace white = . if cps21_vismin_11 == 1 | cps21_vismin_12 == 1
replace white = . if cps21_vismin_1 == . & ///
			  cps21_vismin_2 == . & ///
			  cps21_vismin_3 == . & ///
			  cps21_vismin_5 == . & ///
			  cps21_vismin_6 == . & ///
			  cps21_vismin_7 == . & ///
			  cps21_vismin_8 == .

replace white = . if regexm(other_race, "HUMANOID") & white == 0
replace white = . if regexm(other_race, "COLOURLESS") & white == 0
replace white = . if regexm(other_race, "BANANA")  & white == 0
replace white = . if regexm(other_race, "HIPPOPOTAMUS")  & white == 0
replace white = . if other_race == "MIX"  & white == 0
replace white = . if other_race == "MIXED" & white == 0
replace white = . if other_race == "MIXED RACE" & white == 0
replace white = . if regexm(other_race, "AN INDIVIDUAL") & white == 0
replace white = . if regexm(other_race, "WORLD CITIZEN") & white == 0
replace white = . if regexm(other_race, "PHOENICIA") & white == 0
replace white = . if regexm(other_race, "I DON'T IDENTIFY BY A SKIN COLOUR OR A COUNTRY I DON'T LIVE IN") & white == 0
replace white = . if regexm(other_race, "HUMAN") & white == 0
replace white = . if regexm(other_race, "WHITE IS NOT AN IDENTITY")  & white == 0
replace white = . if regexm(other_race, "I IDENTIFY SOLELY AS ME AND ME ALONE")  & white == 0
replace white = . if regexm(other_race, "RACIST QUESTION") & white == 0
replace white = . if regexm(other_race, "HUMAIN") & white == 0
replace white = . if other_race == "EARTH" & white == 0
replace white = . if other_race == "A PERSON" & white == 0
replace white = . if other_race == "CITOYEN" & white == 0
replace white = . if regexm(other_race, "BI RACIAL") & white == 0
replace white = . if regexm(other_race, "BI-RACIAL") & white == 0
replace white = . if regexm(other_race, "ADOPTED") & white == 0
replace white = . if regexm(other_race, "NON CLASSIFIED") & white == 0
replace white = . if regexm(other_race, "AS A PERSON") & white == 0
replace white = . if regexm(other_race, "MIX CANADIAN - HEINZ 57") & white == 0
replace white = . if regexm(other_race, "MY IDENTITY ISN'T LINKED TO MY SKIN COLOR OR RACE") & white == 0
replace white = . if regexm(other_race, "RESIDENT OF EARTH")  & white == 0
replace white = . if other_race == "MYSELF" & white == 0
replace white = . if regexm(other_race, "IDENTIFYING PEOPLE BY SKIN COLOR IS OFFENSIVE") & white == 0
replace white = . if regexm(other_race, "I NEVER REFER TO  MYSELF BY A COLOUR") & white == 0
replace white = . if other_race == "MIXED NATIONS" & white == 0
replace white = . if regexm(other_race, "CANADIAN MELTING POT") & white == 0
replace white = . if regexm(other_race, "PERSON OF PALLOR") & white == 0
* POSSIBLY IN THE LONG RESPONSE
replace white = . if regexm(other_race, "RACE IS AN ARTIFICIAL CONSTRUCT") & white == 0
replace white = . if regexm(other_race, "A PERSON. I DON'T IDENTIFY WITH A GROUP") & white == 0
replace white = . if regexm(other_race, "MEDITERRANEAN") & white == 0

** GENERATE INDIGENOUS DUMMY
gen indigenous = .

** RECODE CLOSE-ENDED RESPONSES
replace indigenous = 0 if cps21_vismin_4 == -99
replace indigenous = 1 if cps21_vismin_4 == 1

** RECODE OPEN-ENDED RESPONSES
replace indigenous = 1 if regexm(other_race, "METIS")
replace indigenous = 1 if regexm(other_race, "MéTIS")
replace indigenous = 1 if regexm(other_race, "NON STATUS")

** RECODE MISSING
replace indigenous = . if cps21_vismin_11 == 1 | cps21_vismin_12 == 1
replace indigenous = . if cps21_vismin_1 == . & ///
			  cps21_vismin_2 == . & ///
			  cps21_vismin_3 == . & ///
			  cps21_vismin_5 == . & ///
			  cps21_vismin_6 == . & ///
			  cps21_vismin_7 == . & ///
			  cps21_vismin_8 == .

replace indigenous = . if regexm(other_race, "HUMANOID") & indigenous == 0
replace indigenous = . if regexm(other_race, "COLOURLESS") & indigenous == 0
replace indigenous = . if regexm(other_race, "BANANA")  & indigenous == 0
replace indigenous = . if regexm(other_race, "HIPPOPOTAMUS")  & indigenous == 0
replace indigenous = . if other_race == "MIX"  & indigenous == 0
replace indigenous = . if other_race == "MIXED" & indigenous == 0
replace indigenous = . if other_race == "MIXED RACE" & indigenous == 0
replace indigenous = . if regexm(other_race, "AN INDIVIDUAL") & indigenous == 0
replace indigenous = . if regexm(other_race, "WORLD CITIZEN") & indigenous == 0
replace indigenous = . if regexm(other_race, "PHOENICIA") & indigenous == 0
replace indigenous = . if regexm(other_race, "I DON'T IDENTIFY BY A SKIN COLOUR OR A COUNTRY I DON'T LIVE IN") & indigenous == 0
replace indigenous = . if regexm(other_race, "HUMAN") & indigenous == 0
replace indigenous = . if regexm(other_race, "WHITE IS NOT AN IDENTITY")  & indigenous == 0
replace indigenous = . if regexm(other_race, "I IDENTIFY SOLELY AS ME AND ME ALONE")  & indigenous == 0
replace indigenous = . if regexm(other_race, "RACIST QUESTION") & indigenous == 0
replace indigenous = . if regexm(other_race, "HUMAIN") & indigenous == 0
replace indigenous = . if other_race == "EARTH" & indigenous == 0
replace indigenous = . if other_race == "A PERSON" & indigenous == 0
replace indigenous = . if other_race == "CITOYEN" & indigenous == 0
replace indigenous = . if regexm(other_race, "BI RACIAL") & indigenous == 0
replace indigenous = . if regexm(other_race, "BI-RACIAL") & indigenous == 0
replace indigenous = . if regexm(other_race, "ADOPTED") & indigenous == 0
replace indigenous = . if regexm(other_race, "NON CLASSIFIED") & indigenous == 0
replace indigenous = . if regexm(other_race, "AS A PERSON") & indigenous == 0
replace indigenous = . if regexm(other_race, "MIX CANADIAN - HEINZ 57") & indigenous == 0
replace indigenous = . if regexm(other_race, "MY IDENTITY ISN'T LINKED TO MY SKIN COLOR OR RACE") & indigenous == 0
replace indigenous = . if regexm(other_race, "RESIDENT OF EARTH")  & indigenous == 0
replace indigenous = . if other_race == "MYSELF" & indigenous == 0
replace indigenous = . if regexm(other_race, "IDENTIFYING PEOPLE BY SKIN COLOR IS OFFENSIVE") & indigenous == 0
replace indigenous = . if regexm(other_race, "I NEVER REFER TO  MYSELF BY A COLOUR") & indigenous == 0
replace indigenous = . if other_race == "MIXED NATIONS" & indigenous == 0
replace indigenous = . if regexm(other_race, "CANADIAN MELTING POT") & indigenous == 0
replace indigenous = . if regexm(other_race, "PERSON OF PALLOR") & indigenous == 0
* POSSIBLY IN THE LONG RESPONSE
replace indigenous = . if regexm(other_race, "RACE IS AN ARTIFICIAL CONSTRUCT") & indigenous == 0
replace indigenous = . if regexm(other_race, "A PERSON. I DON'T IDENTIFY WITH A GROUP") & indigenous == 0
replace indigenous = . if regexm(other_race, "MEDITERRANEAN") & indigenous == 0

** GENERATE RACIALIZED DUMMY
gen racialized = 0

** RECODE CLOSE-ENDED RESPONSES
replace racialized = 1 if cps21_vismin_1 == 1 | ///
			  cps21_vismin_2 == 1 | ///
			  cps21_vismin_3 == 1 | ///
			  cps21_vismin_5 == 1 | ///
			  cps21_vismin_6 == 1 | ///
			  cps21_vismin_7 == 1 | ///
			  cps21_vismin_8 == 1
			  
** RECODE OPEN-ENDED RESPONSES
replace racialized = 1 if regexm(other_race, "BANGLADESHI")
replace racialized = 1 if regexm(other_race, "INDIAN")
replace racialized = 1 if regexm(other_race, "KABYLE")
replace racialized = 1 if regexm(other_race, "BERBèRE")
replace racialized = 1 if regexm(other_race, "BERBERE")
replace racialized = 1 if regexm(other_race, "LATINO")
replace racialized = 1 if regexm(other_race, "SIKH")
replace racialized = 1 if regexm(other_race, "FIJIAN")
replace racialized = 1 if regexm(other_race, "TRINIDADIAN")
replace racialized = 1 if regexm(other_race, "HAWAIIAN")
replace racialized = 1 if regexm(other_race, "CARIBBEAN")
replace racialized = 1 if regexm(other_race, "KOREAN")
replace racialized = 1 if regexm(other_race, "GUYANESE")
replace racialized = 1 if regexm(other_race, "DAD IS BROWN")
replace racialized = 1 if regexm(other_race, "TAIWANESE")
replace racialized = 1 if regexm(other_race, "MAGHRéBIN")
replace racialized = 1 if regexm(other_race, "SOUTH AMERICAN INDIAN")
replace racialized = 1 if regexm(other_race, "INDO-GUYANESE")
replace racialized = 1 if regexm(other_race, "NORTH AFRICAN")
replace racialized = 1 if regexm(other_race, "PORTUSES GOA")
replace racialized = 1 if regexm(other_race, "CHINESE")
replace racialized = 1 if regexm(other_race, "TURKISH")
replace racialized = 1 if regexm(other_race, "HONGKONGER")
replace racialized = 1 if regexm(other_race, "HONG KONGER")
replace racialized = 1 if regexm(other_race, "SOUTH ASIAN")
replace racialized = 1 if regexm(other_race, "EGYPTIAN")
replace racialized = 1 if regexm(other_race, "MIDDLE EAST")
replace racialized = 1 if regexm(other_race, "SOUTH AMERICAN")
replace racialized = 1 if regexm(other_race, "VISIBLE MINORITY")
replace racialized = 1 if regexm(other_race, "JAPANESE")
replace racialized = 1 if regexm(other_race, "FILIPINO")
replace racialized = 1 if regexm(other_race, "BIPOC")
replace racialized = 1 if regexm(other_race, "MIXED RACE, BLACK AND WHITE")
replace racialized = 1 if regexm(other_race, "WEST CENTRAL ASIAN")
replace racialized = 1 if regexm(other_race, "CONGOLESE")
replace racialized = 1 if regexm(other_race, "ZOROASTRIAN")
replace racialized = 1 if other_race == "BROWN"
replace racialized = 1 if other_race == "TAMIL"
replace racialized = 1 if other_race == "HISPANIC"
replace racialized = 1 if regexm(other_race, "EAST ASIAN")
replace racialized = 1 if regexm(other_race, "INDO CARAIBBEAN")
replace racialized = 1 if regexm(other_race, "HALF ASIAN")
replace racialized = 1 if regexm(other_race, "COPTIC")
replace racialized = 1 if regexm(other_race, "GRAND MAGHREB")

** RECODE MISSING
replace racialized = . if cps21_vismin_11 == 1 | cps21_vismin_12 == 1
replace racialized = . if cps21_vismin_1 == . & ///
			  cps21_vismin_2 == . & ///
			  cps21_vismin_3 == . & ///
			  cps21_vismin_5 == . & ///
			  cps21_vismin_6 == . & ///
			  cps21_vismin_7 == . & ///
			  cps21_vismin_8 == .

replace racialized = . if regexm(other_race, "HUMANOID") & racialized == 0
replace racialized = . if regexm(other_race, "COLOURLESS") & racialized == 0
replace racialized = . if regexm(other_race, "BANANA")  & racialized == 0
replace racialized = . if regexm(other_race, "HIPPOPOTAMUS")  & racialized == 0
replace racialized = . if other_race == "MIX"  & racialized == 0
replace racialized = . if other_race == "MIXED" & racialized == 0
replace racialized = . if other_race == "MIXED RACE" & racialized == 0
replace racialized = . if regexm(other_race, "AN INDIVIDUAL") & racialized == 0
replace racialized = . if regexm(other_race, "WORLD CITIZEN") & racialized == 0
replace racialized = . if regexm(other_race, "PHOENICIA") & racialized == 0
replace racialized = . if regexm(other_race, "I DON'T IDENTIFY BY A SKIN COLOUR OR A COUNTRY I DON'T LIVE IN") & racialized == 0
replace racialized = . if regexm(other_race, "HUMAN") & racialized == 0
replace racialized = . if regexm(other_race, "WHITE IS NOT AN IDENTITY")  & racialized == 0
replace racialized = . if regexm(other_race, "I IDENTIFY SOLELY AS ME AND ME ALONE")  & racialized == 0
replace racialized = . if regexm(other_race, "RACIST QUESTION") & racialized == 0
replace racialized = . if regexm(other_race, "HUMAIN") & racialized == 0
replace racialized = . if other_race == "EARTH" & racialized == 0
replace racialized = . if other_race == "A PERSON" & racialized == 0
replace racialized = . if other_race == "CITOYEN" & racialized == 0
replace racialized = . if regexm(other_race, "BI RACIAL") & racialized == 0
replace racialized = . if regexm(other_race, "BI-RACIAL") & racialized == 0
replace racialized = . if regexm(other_race, "ADOPTED") & racialized == 0
replace racialized = . if regexm(other_race, "NON CLASSIFIED") & racialized == 0
replace racialized = . if regexm(other_race, "AS A PERSON") & racialized == 0
replace racialized = . if regexm(other_race, "MIX CANADIAN - HEINZ 57") & racialized == 0
replace racialized = . if regexm(other_race, "MY IDENTITY ISN'T LINKED TO MY SKIN COLOR OR RACE") & racialized == 0
replace racialized = . if regexm(other_race, "RESIDENT OF EARTH")  & racialized == 0
replace racialized = . if other_race == "MYSELF" & racialized == 0
replace racialized = . if regexm(other_race, "IDENTIFYING PEOPLE BY SKIN COLOR IS OFFENSIVE") & racialized == 0
replace racialized = . if regexm(other_race, "I NEVER REFER TO  MYSELF BY A COLOUR") & racialized == 0
replace racialized = . if other_race == "MIXED NATIONS" & racialized == 0
replace racialized = . if regexm(other_race, "CANADIAN MELTING POT") & racialized == 0
replace racialized = . if regexm(other_race, "PERSON OF PALLOR") & racialized == 0
* POSSIBLY IN THE LONG RESPONSE
replace racialized = . if regexm(other_race, "RACE IS AN ARTIFICIAL CONSTRUCT") & racialized == 0
replace racialized = . if regexm(other_race, "A PERSON. I DON'T IDENTIFY WITH A GROUP") & racialized == 0
replace racialized = . if regexm(other_race, "MEDITERRANEAN") & racialized == 0

list other_race if other_race ~= "-99" & white == 0 & indigenous == 0 & racialized == 0

************************
*** COUNTRY OF BIRTH ***
************************

tab cps21_bornin_canada

gen born_outside_canada = .
replace born_outside_canada = 0 if cps21_bornin_canada == 1
replace born_outside_canada = 1 if cps21_bornin_canada == 2

label define countries 0 "Canada" 1 "Outside Canada"
label values born_outside_canada countries
label variable born_outside_canada "Country of Birth (0 = Canada, 1 = Not Canada)"

**************************
*** CITIZENSHIP STATUS ***
**************************

gen noncitizen = cps21_citizenship - 1
label define citizenship 0 "Citizen" 1 "Non-Citizen (Permanent Resident)"
label values noncitizen citizenship
label variable noncitizen "Citizenship Status (0 = Citizen, 1 = Permanent Resident)"

*********************
*** USER LANGUAGE ***
*********************

gen user_language = 0 if UserLanguage == "EN"
replace user_language = 1 if UserLanguage == "FR-CA"

label define languages 0 "English" 1 "French"
label values user_language languages
label variable user_language "User Language (English/French)"

*********************
*** MOTHER TONGUE ***
*********************

tab cps21_language_1
tab cps21_language_2
tab cps21_language_18

gen anglophone = 0
replace anglophone = 1 if cps21_language_1 == 1
replace anglophone = . if cps21_language_18 == 1 & anglophone == 0

gen francophone = 0
replace francophone = 1 if cps21_language_2 == 1
replace francophone = . if cps21_language_18 == 1 & francophone == 0

gen allophone = 0
replace allophone = 1 if cps21_language_3 == 1 | ///
			 cps21_language_4 == 1 | ///
			 cps21_language_5 == 1 | ///
			 cps21_language_6 == 1 | ///
			 cps21_language_7 == 1 | ///			 
			 cps21_language_8 == 1 | ///
			 cps21_language_9 == 1 | ///			 
			 cps21_language_10 == 1 | ///			 
			 cps21_language_11 == 1 | ///			 
			 cps21_language_12 == 1 | ///			 
			 cps21_language_13 == 1 | ///			 
			 cps21_language_14 == 1 | ///			 
			 cps21_language_15 == 1 | ///
			 cps21_language_16 == 1 | ///
			 cps21_language_17 == 1
			 
replace allophone = . if cps21_language_18 == 1 & allophone == 0

gen bilingual_en_fr = 0 if anglophone == 0 | francophone == 0
replace bilingual_en_fr = 1 if anglophone == 1 & francophone == 1

gen bilingual_en_oth = 0 if anglophone == 0 | allophone == 0
replace bilingual_en_oth = 1 if anglophone == 1 & allophone == 1

gen bilingual_fr_oth = 0 if francophone == 0 | allophone == 0
replace bilingual_fr_oth = 1 if francophone == 1 & allophone == 1

gen trilingual = 0 if anglophone == 0 | francophone == 0 | allophone == 0
replace trilingual = 1 if anglophone == 1 & francophone == 1 & allophone == 1

gen mother_tongue = .
replace mother_tongue = 1 if anglophone == 1
replace mother_tongue = 2 if francophone == 1
replace mother_tongue = 3 if allophone == 1
replace mother_tongue = 4 if bilingual_en_fr == 1
replace mother_tongue = 5 if bilingual_en_oth == 1
replace mother_tongue = 6 if bilingual_fr_oth == 1
replace mother_tongue = 7 if trilingual == 1

label define mother_tongues 1 "English Only" 2 "French Only" 3 "Another Language Only" 4 "English and French" 5 "English and Another Language" 6 "French and Another Language" 7 "English, French, and Another Language"
label values mother_tongue mother_tongues

gen mother_tongue4 = 1 if anglophone == 1 & francophone == 0
replace mother_tongue4 = 2 if anglophone == 0 & francophone == 1
replace mother_tongue4 = 3 if anglophone == 1 & francophone == 1
replace mother_tongue4 = 4 if anglophone == 0 & francophone == 0 & allophone == 1

label define mother_tongues_census 1 "English but not French" 2 "French but not English" 3 "Both English and French" 4 "Neither English Nor French"
label values mother_tongue4 mother_tongues_census

****************
*** RELIGION ***
****************

** CODE CLOSE-ENDED RESPONSES
gen religion = .
replace religion = 0 if cps21_religion == 1 | cps21_religion == 2
replace religion = 1 if cps21_religion == 10
replace religion = 2 if cps21_religion == 8 | ///
			    cps21_religion == 9 | ///
			    cps21_religion == 13 | ///
			    cps21_religion == 16 | ///
			    cps21_religion == 18
replace religion = 3 if cps21_religion == 12 | ///
			    cps21_religion == 14 | ///
			    cps21_religion == 15 | ///
			    cps21_religion == 17 | ///
			    cps21_religion == 19 | ///
			    cps21_religion == 20
replace religion = 4 if cps21_religion == 11 
replace religion = 5 if cps21_religion == 21
replace religion = 6 if cps21_religion == 3 | ///
			cps21_religion == 4 | ///
			cps21_religion == 5 | ///
			cps21_religion == 6 | ///
			cps21_religion == 7

** CODE OPEN-ENDED RESPONSES
gen RELIGION = upper(cps21_religion_22_TEXT) if cps21_religion_22_TEXT ~= "-99"

replace religion = 0 if regexm(RELIGION, "AGNOSTIC")
replace religion = 0 if regexm(RELIGION, "AGNOSTIQUE")
replace religion = 0 if regexm(RELIGION, "ALL RELIGION IS A SCAM")
replace religion = 0 if regexm(RELIGION, "ASHAMED TO BE BAPTIZED CATHOLIC")
replace religion = 0 if regexm(RELIGION, "ATHEE")
replace religion = 0 if regexm(RELIGION, "ATHéE")
replace religion = 0 if regexm(RELIGION, "ATHEIST")
replace religion = 0 if regexm(RELIGION, "ATHESIT")
replace religion = 0 if regexm(RELIGION, "ATHIEST")
replace religion = 0 if regexm(RELIGION, "ATH�")
replace religion = 0 if regexm(RELIGION, "ATH�E")
replace religion = 0 if regexm(RELIGION, "AT�")
replace religion = 0 if regexm(RELIGION, "AUCUN")
replace religion = 0 if regexm(RELIGION, "BAPTIS�E CATHOLIQUE")
replace religion = 0 if regexm(RELIGION, "BORN CATHOLIC BUT DON'T REALLY FOLLOW")
replace religion = 0 if regexm(RELIGION, "BORN CATHOLIC BUT NOT PRACTICING")
replace religion = 0 if regexm(RELIGION, "CATHOLIC AND ANGLICAN")
replace religion = 0 if regexm(RELIGION, "CATHOLIC BUT NOT PRACTICING")
replace religion = 0 if regexm(RELIGION, "CATHOLIC NOT PRACTICING")
replace religion = 0 if regexm(RELIGION, "CATHOLIOQUE NON-PRATIQUANT")
replace religion = 0 if regexm(RELIGION, "CATHOLIQUE DE NAISSANCE MAIS AGNOSTIQ")
replace religion = 0 if regexm(RELIGION, "CATHOLIQUE MAIS NON PRATIQUANT")
replace religion = 0 if regexm(RELIGION, "CATHOLIQUE MON PRATIQUANT")
replace religion = 0 if regexm(RELIGION, "CATHOLIQUE NON PRATICANTE")
replace religion = 0 if regexm(RELIGION, "CATHOLIQUE NON PRATICANTE")
replace religion = 0 if regexm(RELIGION, "CATHOLIQUE NON PRATIQUANT")
replace religion = 0 if regexm(RELIGION, "CATHOLIQUE NON PRATIQUANT")
replace religion = 0 if regexm(RELIGION, "CATHOLIQUE NON PRATIQUANTE")
replace religion = 0 if regexm(RELIGION, "CATHOLIQUE PAR BAPT�ME,NON-PRATIQUANT")
replace religion = 0 if regexm(RELIGION, "CATHOLIQUE PAS PRATIQUANTE")
replace religion = 0 if regexm(RELIGION, "CHRéTIEN (SANS RELIGION)")
replace religion = 0 if regexm(RELIGION, "CHRISTIAN (I CELEBRATE SANTA, THE EAS")
replace religion = 0 if regexm(RELIGION, "CHRISTIAN AND ATHEIST")
replace religion = 0 if regexm(RELIGION, "CHRISTIAN RAISED, BUT QUESTIONING MY ")
replace religion = 0 if regexm(RELIGION, "CHR�TIEN NON PRATIQUANT")
replace religion = 0 if regexm(RELIGION, "CHURCH OF FLYING SPAGHETTI MONSTER")
replace religion = 0 if regexm(RELIGION, "DO NOT SUBSCRIBE TO ORGANISED RELEGION")
replace religion = 0 if regexm(RELIGION, "DON'T BELIEVE IN ORGANIZED RELIGION")
replace religion = 0 if regexm(RELIGION, "DON'T BELIEVE IN RELIGION")
replace religion = 0 if regexm(RELIGION, "DON'T SUBSCRIBE TO ANY RELIGION BUT A")
replace religion = 0 if regexm(RELIGION, "DONT BELIEVE IN ANY RELIGION...EARTH ")
replace religion = 0 if regexm(RELIGION, "EVIDENTIALIST")
replace religion = 0 if regexm(RELIGION, "EX-CATHOLIC")
replace religion = 0 if regexm(RELIGION, "FORMERLY RC, NO LONGER SUPPORT ORGANI")
replace religion = 0 if regexm(RELIGION, "FREE THINKER")
replace religion = 0 if regexm(RELIGION, "FSM")
replace religion = 0 if regexm(RELIGION, "I DO NOT PRACTICE")
replace religion = 0 if regexm(RELIGION, "I DON'T BEIEVE IN RELIGION. I AM A C")
replace religion = 0 if regexm(RELIGION, "I DON'T FOLLOW ANY RELIGION NOR BROUG")
replace religion = 0 if regexm(RELIGION, "I DON’T CARE")
replace religion = 0 if regexm(RELIGION, "I THINK ONE RELIGIOUS OUTLOOK IS JUST")
replace religion = 0 if regexm(RELIGION, "I WAS ROMAN CATHOLIC, BUT I STOPPED ")
replace religion = 0 if regexm(RELIGION, "INACTIVE JEHOVAH WITNESS")
replace religion = 0 if regexm(RELIGION, "J'AI �T� �LEV� CATHOLIQUE.")
replace religion = 0 if regexm(RELIGION, "J'éTAIS CATHOLIQUE")
replace religion = 0 if regexm(RELIGION, "J'éTAIS CATHOLIQUE PAR MON éDUCATION ")
replace religion = 0 if regexm(RELIGION, "JEWISH BY BIRTH AND ATHEIST BY CHOICE")
replace religion = 0 if regexm(RELIGION, "LAPSED CATHOLIC")
replace religion = 0 if regexm(RELIGION, "LAPSED ROMAN CATHOLIC")
replace religion = 0 if regexm(RELIGION, "NO")
replace religion = 0 if regexm(RELIGION, "NO AFFILIATION")
replace religion = 0 if regexm(RELIGION, "NO ORGANIZED RELIGIOUS AFFILIATION")
replace religion = 0 if regexm(RELIGION, "NO RELIGION")
replace religion = 0 if regexm(RELIGION, "NO RELIGON")
replace religion = 0 if regexm(RELIGION, "NO SPECIFIC ONE")
replace religion = 0 if regexm(RELIGION, "NON PRACTICING")
replace religion = 0 if regexm(RELIGION, "NON PRACTISING")
replace religion = 0 if regexm(RELIGION, "NON PRATIQUANT")
replace religion = 0 if regexm(RELIGION, "NON RELIGIOUS")
replace religion = 0 if regexm(RELIGION, "NON- DEMINAL")
replace religion = 0 if regexm(RELIGION, "NON-PRACTICING CATHOLIC TO BE SPECIFIC")
replace religion = 0 if regexm(RELIGION, "NON-RELIGIOUS")
replace religion = 0 if regexm(RELIGION, "NONE")
replace religion = 0 if regexm(RELIGION, "NONE IT'S A CULT")
replace religion = 0 if regexm(RELIGION, "NONE NON-ATHEIST")
replace religion = 0 if regexm(RELIGION, "NONE PRACTICING CATHOLIC")
replace religion = 0 if regexm(RELIGION, "NONRELIGIOUS")
replace religion = 0 if regexm(RELIGION, "NOT A CHURCH-GOER")
replace religion = 0 if regexm(RELIGION, "NOT ACTIVE CATHOLIC")
replace religion = 0 if regexm(RELIGION, "NOT AFFILIATED WITH ANY BUT BELIEVE I")
replace religion = 0 if regexm(RELIGION, "NOT RELIGIOUS")
replace religion = 0 if regexm(RELIGION, "NOT RELIGIOUS")
replace religion = 0 if regexm(RELIGION, "NOT RELIGIOUS, BUT NOT SURE IF GOD EX")
replace religion = 0 if regexm(RELIGION, "NOT RELIGISH")
replace religion = 0 if regexm(RELIGION, "NOT SURE ANYMORE")
replace religion = 0 if regexm(RELIGION, "NOTHING")
replace religion = 0 if regexm(RELIGION, "NOTHING ORGANIZED")
replace religion = 0 if regexm(RELIGION, "ONCE UPON A TIME, CHRISTIAN; NOW, AGN")
replace religion = 0 if regexm(RELIGION, "ONLY BELIEVE IN SCIENCE")
replace religion = 0 if regexm(RELIGION, "PAS DE RELIGION")
replace religion = 0 if regexm(RELIGION, "PASTAFARIAN")
replace religion = 0 if regexm(RELIGION, "PASTAFARIAN")
replace religion = 0 if regexm(RELIGION, "PASTAFARIANISM")
replace religion = 0 if regexm(RELIGION, "PASTAFARIEN")
replace religion = 0 if regexm(RELIGION, "RAISED CATHOLIC. BUT DO NOT BELIEVE T")
replace religion = 0 if regexm(RELIGION, "RC, NOT PRACTICING")
replace religion = 0 if regexm(RELIGION, "RECOVERING CATHOLIC")
replace religion = 0 if regexm(RELIGION, "RELIGION IS A CRIMINAL ENTERPRISE")
replace religion = 0 if regexm(RELIGION, "RELIGION IS BULLSHIT")
replace religion = 0 if regexm(RELIGION, "RELIGION IS ONLY FOR THE NAIVE AND WE")
replace religion = 0 if regexm(RELIGION, "RELIGION ONLY CAUSES PROBLEMS - I LIV")
replace religion = 0 if regexm(RELIGION, "RELIGIONS ARE CULTS. JUST LIVE YOUR L")
replace religion = 0 if regexm(RELIGION, "RIEN")
replace religion = 0 if regexm(RELIGION, "ROMAN CATHOLIC BUT DO NOT PRACTICE")
replace religion = 0 if regexm(RELIGION, "SECULAR HUMANIST")
replace religion = 0 if regexm(RELIGION, "TOLERANT ATHIEST")
replace religion = 0 if regexm(RELIGION, "WAS CATHOLIC BUT WITH ALL THEY DID TO")
replace religion = 1 if regexm(RELIGION, "BAPTISED AS CATHOLIC BUT NOT PRACTISING")
replace religion = 1 if regexm(RELIGION, "CATHOLIC")
replace religion = 1 if regexm(RELIGION, "CATHOLIC")
replace religion = 1 if regexm(RELIGION, "CATHOLIC/CHRISTIAN")
replace religion = 1 if regexm(RELIGION, "CATHOLIQUE")
replace religion = 1 if regexm(RELIGION, "CATHOLIQUE")
replace religion = 1 if regexm(RELIGION, "CATHOLIQUE PRARIQUANTE")
replace religion = 1 if regexm(RELIGION, "CATOLIQUE")
replace religion = 1 if regexm(RELIGION, "CHRISTIAN-CATHOLIC")
replace religion = 1 if regexm(RELIGION, "CHRISTIAN/CATHOLIC")
replace religion = 1 if regexm(RELIGION, "éDUCATION CHRéTIENNE CATHOLIQUE")
replace religion = 1 if regexm(RELIGION, "GAY CATHOLIC")
replace religion = 1 if regexm(RELIGION, "GREEK CATHOLIC")
replace religion = 1 if regexm(RELIGION, "ROMAN CATHOLIC")
replace religion = 1 if regexm(RELIGION, "UKRAINIAN CATHOLIC")
replace religion = 1 if regexm(RELIGION, "UKRAINIAN GREEK CATHOLIC")
replace religion = 1 if regexm(RELIGION, "UKRANIAN CATHOLIC")
replace religion = 2 if regexm(RELIGION, "ANGLICAN")
replace religion = 2 if regexm(RELIGION, "ANGLICAN")
replace religion = 2 if regexm(RELIGION, "ANGLICAN CHURCH OF CANADA")
replace religion = 2 if regexm(RELIGION, "ANGLICAN NETWORK OF CANADA")
replace religion = 2 if regexm(RELIGION, "ANGLICAN/ CHURCH OF CANADA")
replace religion = 2 if regexm(RELIGION, "BABTIST")
replace religion = 2 if regexm(RELIGION, "BAPTIST")
replace religion = 2 if regexm(RELIGION, "BAPTIST")
replace religion = 2 if regexm(RELIGION, "BAPTIST CHRISTIAN")
replace religion = 2 if regexm(RELIGION, "BAPTIST; CHRISTIAN")
replace religion = 2 if regexm(RELIGION, "GOING TO A BAPTIST, BUT CHRISTENED AS")
replace religion = 2 if regexm(RELIGION, "LUTHERAN")
replace religion = 2 if regexm(RELIGION, "LUTHREN")
replace religion = 2 if regexm(RELIGION, "METHODIST")
replace religion = 2 if regexm(RELIGION, "METHODIST")
replace religion = 2 if regexm(RELIGION, "PRESBYTERIAN")
replace religion = 2 if regexm(RELIGION, "PRESBYTERIAN CHURCH")
replace religion = 2 if regexm(RELIGION, "SPIRITUAL BAPTIST")
replace religion = 2 if regexm(RELIGION, "TRADITIONAL ANGLICAN CHURCH")
replace religion = 2 if regexm(RELIGION, "UNITED - CHRISTIAN")
replace religion = 2 if regexm(RELIGION, "UNITED CHURCH")
replace religion = 3 if regexm(RELIGION, "7TH DAY ADVENTIST")
replace religion = 3 if regexm(RELIGION, "ADVENTIST")
replace religion = 3 if regexm(RELIGION, "ADVENTIST")
replace religion = 3 if regexm(RELIGION, "ADVENTISTE DU 7E JOUR")
replace religion = 3 if regexm(RELIGION, "ADVENTISTE DU SEPTI�ME JOUR")
replace religion = 3 if regexm(RELIGION, "AGC")
replace religion = 3 if regexm(RELIGION, "ALLIANCE")
replace religion = 3 if regexm(RELIGION, "ALLIANCE")
replace religion = 3 if regexm(RELIGION, "ALLIANCE CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "ASSOCIATED GOSPEL CHURCH")
replace religion = 3 if regexm(RELIGION, "BELIEVE JESUS IS OUR LORD AND SAVIOUR")
replace religion = 3 if regexm(RELIGION, "BORN AGAIN CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "BORN AGAIN CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "BORN AGAIN CHRISTIAN EVANGELICAL")
replace religion = 3 if regexm(RELIGION, "BORN AGAIN CHRISTIAN INDEPENDENT")
replace religion = 3 if regexm(RELIGION, "BORN-AGAIN CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "BOTH ANGLICAN AND PENTECOSTAL")
replace religion = 3 if regexm(RELIGION, "CANADIAN REFORMED")
replace religion = 3 if regexm(RELIGION, "CANADIAN REFORMED - CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "CANADIAN REFORMED CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "CHRéTIENNE éVANGéLISTE")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN - NAZARENE")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN - NON DENOMINATIONAL")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN - NON-DENOMINATIONAL")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN - SPIRITUAL")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN - UNDENOMINATIONAL")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN (CHURCH OF CHRIST)")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN (NO PARTICULAR DENOMINATION)")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN (NON DENOMINATIONAL)")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN (NON-DENOMINATIONAL). CHURC")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN ALLIANCE")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN AND MISSIONARY ALLIANCE")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN MISSIONARY AND ALLIANCE")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN NON DENOMINATIONAL")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN NON DENOMINATIONAL")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN NON-DENOM")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN NON-DENOMINATIONAL")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN NON-DENOMINATIONAL")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN-NON DENOMINATIONAL")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN-NON DENOMINATIONAL")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN, NON DENOMINATIONAL CHARISM")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN, NON-DENOMINATIONAL")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN/CANADIAN REFORMED")
replace religion = 3 if regexm(RELIGION, "CHRISTIAN/EVANGELICAL")
replace religion = 3 if regexm(RELIGION, "CHURCH OF JESUS CHRIST OF LATTER DAY ")
replace religion = 3 if regexm(RELIGION, "CHURCH OF THE LATTER DAY DUDE")
replace religion = 3 if regexm(RELIGION, "COMMUNITY OF CHRIST")
replace religion = 3 if regexm(RELIGION, "EAST GATE ALLIANCE, PROTESTANT CHURCH")
replace religion = 3 if regexm(RELIGION, "EVANGELICAL")
replace religion = 3 if regexm(RELIGION, "EVANGELICAL")
replace religion = 3 if regexm(RELIGION, "EVANGELICAL CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "EVANGELICAL CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "EVANGELICAL CHRISTIAN BUT NOT FUNDAME")
replace religion = 3 if regexm(RELIGION, "EVANGELICAL CHRISTIAN WHO CURRENTLY A")
replace religion = 3 if regexm(RELIGION, "EVANGELICAL FREE")
replace religion = 3 if regexm(RELIGION, "EVANGELICAL MISSIONARY ALLIANCE")
replace religion = 3 if regexm(RELIGION, "ÉVANGéLIQUE")
replace religion = 3 if regexm(RELIGION, "ÉVANGéLIQUE BAPTISTE")
replace religion = 3 if regexm(RELIGION, "EVANGELIST")
replace religion = 3 if regexm(RELIGION, "EVANGELIST CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "EVANGELISTIC")
replace religion = 3 if regexm(RELIGION, "FREE METHODIST")
replace religion = 3 if regexm(RELIGION, "FREE METHODIST")
replace religion = 3 if regexm(RELIGION, "FULL GOSPEL CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "GRACE COMMUNION")
replace religion = 3 if regexm(RELIGION, "LATTER-DAY SAINT")
replace religion = 3 if regexm(RELIGION, "LDS/CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "MISSIONARY")
replace religion = 3 if regexm(RELIGION, "MISSIONARY ALLIANCE")
replace religion = 3 if regexm(RELIGION, "MORMON")
replace religion = 3 if regexm(RELIGION, "NAZARENE")
replace religion = 3 if regexm(RELIGION, "NEW APOSTOLIC")
replace religion = 3 if regexm(RELIGION, "NEW APOSTOLIC CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "NON DEMONINATIONAL EVANGELICAL")
replace religion = 3 if regexm(RELIGION, "NON DENOMINATION")
replace religion = 3 if regexm(RELIGION, "NON DENOMINATION")
replace religion = 3 if regexm(RELIGION, "NON DENOMINATION CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "NON DENOMINATIONAL")
replace religion = 3 if regexm(RELIGION, "NON DENOMINATIONAL")
replace religion = 3 if regexm(RELIGION, "NON DENOMINATIONAL BELIEF - DO NOT FO")
replace religion = 3 if regexm(RELIGION, "NON DENOMINATIONAL CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "NON DENOMINATIONAL CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "NON DENOMINATIONAL CHRISTIAN I FOLLOW")
replace religion = 3 if regexm(RELIGION, "NON-DENOMINATION CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "NON-DENOMINATIONAL BIBLE BELIEVING EV")
replace religion = 3 if regexm(RELIGION, "NON-DENOMINATIONAL CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "NON-DENOMINATIONAL CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "NON-DENOMINATIONAL CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "NONDENOMINATIONAL")
replace religion = 3 if regexm(RELIGION, "NONDENOMINATIONAL")
replace religion = 3 if regexm(RELIGION, "NONDENOMINATIONAL CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "NONDENOMINATIONAL CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "PENNE COSTAL CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "PENTECOSTAL")
replace religion = 3 if regexm(RELIGION, "PENTECOSTAL")
replace religion = 3 if regexm(RELIGION, "RED LETTER CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "REFORMED (PART OF THE REFORMATION AS")
replace religion = 3 if regexm(RELIGION, "REFORMED CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "REFORMED.  PROTESTANT")
replace religion = 3 if regexm(RELIGION, "RESTORATIONIST")
replace religion = 3 if regexm(RELIGION, "SDA")
replace religion = 3 if regexm(RELIGION, "SDA")
replace religion = 3 if regexm(RELIGION, "SEVENTH DAY ADVENTIST")
replace religion = 3 if regexm(RELIGION, "SEVENTH DAY ADVENTIST")
replace religion = 3 if regexm(RELIGION, "SEVENTH DAY ADVENTIST")
replace religion = 3 if regexm(RELIGION, "SEVENTH DAY ADVENTIST CHRISTIAN")
replace religion = 3 if regexm(RELIGION, "SEVENTH DAY ADVENTIST/CATHOLIC")
replace religion = 3 if regexm(RELIGION, "SEVENTH-DAY ADVENTIS")
replace religion = 3 if regexm(RELIGION, "SEVENTH-DAY ADVENTIST")
replace religion = 3 if regexm(RELIGION, "SEVENTH-DAY ADVENTIST")
replace religion = 3 if regexm(RELIGION, "SEVENTH-DAY ADVISTIST")
replace religion = 3 if regexm(RELIGION, "SEVENTHDAY ADVENTIST")
replace religion = 3 if regexm(RELIGION, "STUDY AND TRUST JEHOVAH WITNESSES")
replace religion = 3 if regexm(RELIGION, "THE CHURCH OF LATTER DAY SAINTS   ")
replace religion = 3 if regexm(RELIGION, "VINEYARD")
replace religion = 3 if regexm(RELIGION, "WESLEYAN")
replace religion = 3 if regexm(RELIGION, "WESLEYAN")
replace religion = 3 if regexm(RELIGION, "WESLEYAN CHURCH")
replace religion = 3 if regexm(RELIGION, "WESLYAN")
replace religion = 4 if regexm(RELIGION, "(CHRISTIAN) ANABAPTIST")
replace religion = 4 if regexm(RELIGION, "ANABAPTIST")
replace religion = 4 if regexm(RELIGION, "ANABAPTIST")
replace religion = 4 if regexm(RELIGION, "ARMENIAN APOSTOLIC CHIRCH")
replace religion = 4 if regexm(RELIGION, "ARMENIAN ORTATOX")
replace religion = 4 if regexm(RELIGION, "CHRISRIAN")
replace religion = 4 if regexm(RELIGION, "CHRISTIAN ORTHODOXE")
replace religion = 4 if regexm(RELIGION, "COPTIC ORTHODOX")
replace religion = 4 if regexm(RELIGION, "MARONITE")
replace religion = 4 if regexm(RELIGION, "MELKITE")
replace religion = 4 if regexm(RELIGION, "ORTHODOX")
replace religion = 4 if regexm(RELIGION, "ORTHODOX CHRISTIAN")
replace religion = 4 if regexm(RELIGION, "ORTHODOX FROM EAST CHURCH OF IRAQ")
replace religion = 4 if regexm(RELIGION, "ORTODOKC")
replace religion = 4 if regexm(RELIGION, "SERBIAN ORTHRODOX")
replace religion = 4 if regexm(RELIGION, "UKRAINIANN ORTHODOX")
replace religion = 5 if regexm(RELIGION, "A BELIEVER IN JESUS CHRIST AS THE SO")
replace religion = 5 if regexm(RELIGION, "A BELIEVER OF CHRIST.")
replace religion = 5 if regexm(RELIGION, "ANISH")
replace religion = 5 if regexm(RELIGION, "APOLSTOLIC")
replace religion = 5 if regexm(RELIGION, "APOSTALIC")
replace religion = 5 if regexm(RELIGION, "APOSTOLIC")
replace religion = 5 if regexm(RELIGION, "APOSTOLIC")
replace religion = 5 if regexm(RELIGION, "BAPTIZED IN THE CHRISTIAN CHURCH")
replace religion = 5 if regexm(RELIGION, "BELIEVE IN GOD AND JESUS JUST NOT CHU")
replace religion = 5 if regexm(RELIGION, "BELIEVE IN GOD, JESUS, HOLY SPIRIT")
replace religion = 5 if regexm(RELIGION, "BIBLE BELIEVER")
replace religion = 5 if regexm(RELIGION, "BIBLE BELIEVING, GOD FEARING, UNDENOM")
replace religion = 5 if regexm(RELIGION, "BRETHREN IN CHRIST")
replace religion = 5 if regexm(RELIGION, "CATHOLIQUE DE NAISSANCE MAIS CHR�TIEN")
replace religion = 5 if regexm(RELIGION, "CHISTIAN")
replace religion = 5 if regexm(RELIGION, "CHRéTIEN")
replace religion = 5 if regexm(RELIGION, "CHRETIENNE")
replace religion = 5 if regexm(RELIGION, "CHRéTIENNE")
replace religion = 5 if regexm(RELIGION, "CHRéTIENNE NON CATHOLIQUE")
replace religion = 5 if regexm(RELIGION, "CHRISTADELPHIAN")
replace religion = 5 if regexm(RELIGION, "CHRISTADELPHIAN")
replace religion = 5 if regexm(RELIGION, "CHRISTAIN")
replace religion = 5 if regexm(RELIGION, "CHRISTAIN")
replace religion = 5 if regexm(RELIGION, "CHRISTAINS GATHERED TO THE NAME OF OU")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN CATHOLIC")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN - ALL DENOMINATIONS")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN - I DON'T IDENTIFY WITH ANY")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN - NOT REFORMED, JUST SIMPLY")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN (OTHER)")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN (UNSPECIFIED)")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN BELIEFS BUT NO RELIGIOUS AF")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN BRETHREN")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN BRTETHREN")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN CHURCH DISCIPLES OF CHRIST")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN DON'T CARE ABOUT DENOMINATION")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN FALLOWER OF GOD")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN GENERAL")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN JUST NOT EVANGELICAL OR FUN")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN NO REAL ALLEGIANCE TO ANY O")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN NOT AFFILIATED WITH ANY CHU")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN OTHER")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN SCIENCE")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN SCIENTOLOGIST")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN SPITITUAL")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN WITH NO CHURCH AFFILIATION")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN, BUT NOT CATHOLIC, BUT NO P")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN, NO AFFILIATION")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN, NO NEED TO FURTHER DISTING")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN, OTHER THAN ABOVE.")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN, SPIRITUAL")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN, UNAFFILIATED")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN.")
replace religion = 5 if regexm(RELIGION, "CHRISTIAN. NO SPECIFIC CHURCH")
replace religion = 5 if regexm(RELIGION, "CHRISTIANITY")
replace religion = 5 if regexm(RELIGION, "CHRISTIANITY")
replace religion = 5 if regexm(RELIGION, "CHRISTINITY")
replace religion = 5 if regexm(RELIGION, "CHR�TIEN")
replace religion = 5 if regexm(RELIGION, "CHR�TIEN 100 %")
replace religion = 5 if regexm(RELIGION, "CHR�TIENNE")
replace religion = 5 if regexm(RELIGION, "CHURCH OF ANTIOCH")
replace religion = 5 if regexm(RELIGION, "CHURCH OF CHRIST")
replace religion = 5 if regexm(RELIGION, "CHURCH OF CHRIST")
replace religion = 5 if regexm(RELIGION, "CHURCH OF CHRIST (IGLESIA NI CRISTO)")
replace religion = 5 if regexm(RELIGION, "CHURCH OF GOD")
replace religion = 5 if regexm(RELIGION, "CHURCH OF GOD")
replace religion = 5 if regexm(RELIGION, "CHURCH OF GOD INTERNATIONAL")
replace religion = 5 if regexm(RELIGION, "CRISTIAN")
replace religion = 5 if regexm(RELIGION, "DOUKABOR")
replace religion = 5 if regexm(RELIGION, "DOUKABOUR")
replace religion = 5 if regexm(RELIGION, "DOUKHOBOR")
replace religion = 5 if regexm(RELIGION, "DOUKHOBOUR")
replace religion = 5 if regexm(RELIGION, "FOLLOWER OF CHRIST.")
replace religion = 5 if regexm(RELIGION, "FOLLOWER OF JESUS CHRIST")
replace religion = 5 if regexm(RELIGION, "GENERAL CHRISTIAN")
replace religion = 5 if regexm(RELIGION, "GENERAL CHRISTIAN")
replace religion = 5 if regexm(RELIGION, "GENERAL ENVIRONMENTAL CHRISTIAN")
replace religion = 5 if regexm(RELIGION, "I AM A CHRIST FOLLOWER")
replace religion = 5 if regexm(RELIGION, "I AM CHRISTIAN NO CHURCH GROUP")
replace religion = 5 if regexm(RELIGION, "I AM CHRISTIAN, ALL THESE DENOMINATIO")
replace religion = 5 if regexm(RELIGION, "I BELIEVE IN GOD OUR HEAVENLY FATHER ")
replace religion = 5 if regexm(RELIGION, "I FOLLOW CHRIST.")
replace religion = 5 if regexm(RELIGION, "I FOLLOW G-D'S ONE AND ONLY COVENENT ")
replace religion = 5 if regexm(RELIGION, "I PREFER TO SAY CHRISTIAN & NOT A SPE")
replace religion = 5 if regexm(RELIGION, "I SIMPLY JUST BELIEVE IN GOD/JESUS")
replace religion = 5 if regexm(RELIGION, "IAM CHRISTAIN DONT BELONG TO ANY CHURCH")
replace religion = 5 if regexm(RELIGION, "IGLESIA NI CRISTO")
replace religion = 5 if regexm(RELIGION, "IGLESIA NI CRISTO")
replace religion = 5 if regexm(RELIGION, "IGLESIA NI CRISTO (CHURCH OF CHRIST)")
replace religion = 5 if regexm(RELIGION, "INDEPENDENT CHRISTIAN")
replace religion = 5 if regexm(RELIGION, "JESUS CHRIST FOLLOWER")
replace religion = 5 if regexm(RELIGION, "JESUS FOLLOWER")
replace religion = 5 if regexm(RELIGION, "JESUS IS THE "ONLY" WAY")
replace religion = 5 if regexm(RELIGION, "JUST A "CHRISTIAN"!")
replace religion = 5 if regexm(RELIGION, "JUST CHRISTIAN")
replace religion = 5 if regexm(RELIGION, "JUST CHRISTIAN")
replace religion = 5 if regexm(RELIGION, "JUSTE CHRETIEN")
replace religion = 5 if regexm(RELIGION, "LIVING CHURCH OF GOD")
replace religion = 5 if regexm(RELIGION, "MORAVIAN")
replace religion = 5 if regexm(RELIGION, "MORAVIAN")
replace religion = 5 if regexm(RELIGION, "NETHERLANDS CHRISTIAN REFORMED")
replace religion = 5 if regexm(RELIGION, "NON-CHURCH CHRISTIAN VALUES")
replace religion = 5 if regexm(RELIGION, "NON-CHURCH GOING CHRISTIAN")
replace religion = 5 if regexm(RELIGION, "OTHER CHRISTIAN")
replace religion = 5 if regexm(RELIGION, "PLYMOUTH BRETHREN")
replace religion = 5 if regexm(RELIGION, "QUAKER")
replace religion = 5 if regexm(RELIGION, "QUAKER")
replace religion = 5 if regexm(RELIGION, "SIMPLE CHRISTIAN")
replace religion = 5 if regexm(RELIGION, "SOMEWHAT CHRISTIAN (NOT STRONGLY RELI")
replace religion = 5 if regexm(RELIGION, "SPIRIT FILLED CHRISTIAN")
replace religion = 5 if regexm(RELIGION, "SPIRITUAL I BELIEVE IN THE HOLY TRINI")
replace religion = 5 if regexm(RELIGION, "SPIRITUAL JESUS")
replace religion = 5 if regexm(RELIGION, "THE NEW TRANSCRIPTS,TESTAMENT,ORDER O")
replace religion = 5 if regexm(RELIGION, "UNAFFILIATED CHRISTIAN")
replace religion = 5 if regexm(RELIGION, "UNITARIAN")
replace religion = 5 if regexm(RELIGION, "UNITARIAN")
replace religion = 5 if regexm(RELIGION, "UNITARIAN UNIVERSALIST")
replace religion = 5 if regexm(RELIGION, "UNITARIAN UNIVERSALIST")
replace religion = 5 if regexm(RELIGION, "UNITARIAN UNIVERSALIST (BUT I RARELY ")
replace religion = 6 if regexm(RELIGION, "1ST NATIONS ABORIGINAL")
replace religion = 6 if regexm(RELIGION, "ABORIGINAL")
replace religion = 6 if regexm(RELIGION, "ABORIGINAL ( CREATOR)")
replace religion = 6 if regexm(RELIGION, "ABORIGINAL BELIEFS")
replace religion = 6 if regexm(RELIGION, "ABORIGINAL SPIRITUALITY")
replace religion = 6 if regexm(RELIGION, "ABORIGINAL SPIRITUALITY.")
replace religion = 6 if regexm(RELIGION, "ABORIGINAL/TRADITIONAL/SPIRITUAL")
replace religion = 6 if regexm(RELIGION, "ANCESTRAL WITCHCRAFT")
replace religion = 6 if regexm(RELIGION, "ANIMIST")
replace religion = 6 if regexm(RELIGION, "ANIMISTE")
replace religion = 6 if regexm(RELIGION, "ASATRU")
replace religion = 6 if regexm(RELIGION, "ASATRU")
replace religion = 6 if regexm(RELIGION, "ASTARU")
replace religion = 6 if regexm(RELIGION, "BA'HAI")
replace religion = 6 if regexm(RELIGION, "BAHA'I")
replace religion = 6 if regexm(RELIGION, "BAHA'I")
replace religion = 6 if regexm(RELIGION, "BAHA'I FAITH")
replace religion = 6 if regexm(RELIGION, "BAHá'í FAITH")
replace religion = 6 if regexm(RELIGION, "BAHA'IE")
replace religion = 6 if regexm(RELIGION, "BAHA’I")
replace religion = 6 if regexm(RELIGION, "BAHAI")
replace religion = 6 if regexm(RELIGION, "BAHAI")
replace religion = 6 if regexm(RELIGION, "BAHAI'I")
replace religion = 6 if regexm(RELIGION, "BELIEVE IN CREATOR BUT NOT RELIGION")
replace religion = 6 if regexm(RELIGION, "BELIEVE MORE IN A SPIRITUAL FEELING F")
replace religion = 6 if regexm(RELIGION, "BLACK PAGAN WITCH")
replace religion = 6 if regexm(RELIGION, "BLEAVE IN GOD DON'T FOLLOW ANY REILG")
replace religion = 6 if regexm(RELIGION, "BOUDHISTE")
replace religion = 6 if regexm(RELIGION, "BUDDHIST")
replace religion = 6 if regexm(RELIGION, "BUDDHIST")
replace religion = 6 if regexm(RELIGION, "BUDDIST")
replace religion = 6 if regexm(RELIGION, "CELTIC")
replace religion = 6 if regexm(RELIGION, "CHURCH OF SATAN")
replace religion = 6 if regexm(RELIGION, "CLOSEST TO WICCAN, I’D SAY.")
replace religion = 6 if regexm(RELIGION, "CONFUCIANISM")
replace religion = 6 if regexm(RELIGION, "DRUID")
replace religion = 6 if regexm(RELIGION, "DRUID")
replace religion = 6 if regexm(RELIGION, "DRUID, REFORM")
replace religion = 6 if regexm(RELIGION, "DRUID, REFORM")
replace religion = 6 if regexm(RELIGION, "DRUZE")
replace religion = 6 if regexm(RELIGION, "DRUZE")
replace religion = 6 if regexm(RELIGION, "ECKANKAR")
replace religion = 6 if regexm(RELIGION, "ECKANKAR")
replace religion = 6 if regexm(RELIGION, "ECKANKAR VOIE DE LA LIBERTÉ SPIRITUELLE")
replace religion = 6 if regexm(RELIGION, "ECKIST")
replace religion = 6 if regexm(RELIGION, "ECKIST")
replace religion = 6 if regexm(RELIGION, "ESPIRITIST")
replace religion = 6 if regexm(RELIGION, "FIRST NATION")
replace religion = 6 if regexm(RELIGION, "FIRST NATIONS SPIRITUALITY")
replace religion = 6 if regexm(RELIGION, "FIRST NATIONS TEACHINGS")
replace religion = 6 if regexm(RELIGION, "FIRST NATIONS TRADITIONAL")
replace religion = 6 if regexm(RELIGION, "GNOSTIC")
replace religion = 6 if regexm(RELIGION, "GNOSTIC")
replace religion = 6 if regexm(RELIGION, "GNOSTIQUE")
replace religion = 6 if regexm(RELIGION, "GODDESS PACHAMAMA")
replace religion = 6 if regexm(RELIGION, "HARE KRISHNA")
replace religion = 6 if regexm(RELIGION, "I'M WICCA")
replace religion = 6 if regexm(RELIGION, "INDEGIONAS")
replace religion = 6 if regexm(RELIGION, "INDIGENOUS")
replace religion = 6 if regexm(RELIGION, "INDIGENOUS")
replace religion = 6 if regexm(RELIGION, "INDIGENOUS SPIRITUALITY")
replace religion = 6 if regexm(RELIGION, "INDIGENOUS. BELIEVE IN THE CREATOR.")
replace religion = 6 if regexm(RELIGION, "ISKCON - HARE KRISHNA")
replace religion = 6 if regexm(RELIGION, "ISLAM")
replace religion = 6 if regexm(RELIGION, "ISMAILI")
replace religion = 6 if regexm(RELIGION, "JAIN")
replace religion = 6 if regexm(RELIGION, "JAIN")
replace religion = 6 if regexm(RELIGION, "JAINISM")
replace religion = 6 if regexm(RELIGION, "JEWISH")
replace religion = 6 if regexm(RELIGION, "JEWISH")
replace religion = 6 if regexm(RELIGION, "KEMETIC")
replace religion = 6 if regexm(RELIGION, "LAVEYAN SATANISM")
replace religion = 6 if regexm(RELIGION, "LUCIFER, AM�NADIEL, CUPIDON, DIANA (W")
replace religion = 6 if regexm(RELIGION, "LUCIFERIANISM")
replace religion = 6 if regexm(RELIGION, "MESSIANIC/HEBREW ROOTS")
replace religion = 6 if regexm(RELIGION, "MOHAWK")
replace religion = 6 if regexm(RELIGION, "MUSLIM")
replace religion = 6 if regexm(RELIGION, "MUSLIUM AND LUTHERAN")
replace religion = 6 if regexm(RELIGION, "MUSULMAN")
replace religion = 6 if regexm(RELIGION, "M�TIS")
replace religion = 6 if regexm(RELIGION, "NATIVE")
replace religion = 6 if regexm(RELIGION, "NATIVE")
replace religion = 6 if regexm(RELIGION, "NATIVE AMERICAN")
replace religion = 6 if regexm(RELIGION, "NATIVE AMERICAN CHURCH (PEYOTE)")
replace religion = 6 if regexm(RELIGION, "NATIVE AMERICAN, I BELIEVE THE CREATO")
replace religion = 6 if regexm(RELIGION, "NATIVE CANADIAN")
replace religion = 6 if regexm(RELIGION, "NATIVE SPIRITISM")
replace religion = 6 if regexm(RELIGION, "NATIVE SPIRITUAL")
replace religion = 6 if regexm(RELIGION, "NATIVE SPIRITUALISM")
replace religion = 6 if regexm(RELIGION, "NATIVE SPIRITUALITY")
replace religion = 6 if regexm(RELIGION, "NATIVE SPIRITUALITY")
replace religion = 6 if regexm(RELIGION, "NATIVE TRADITION")
replace religion = 6 if regexm(RELIGION, "NEO DRUID")
replace religion = 6 if regexm(RELIGION, "NEO PAGAN")
replace religion = 6 if regexm(RELIGION, "NEW AGE")
replace religion = 6 if regexm(RELIGION, "NEW AGE METAPHYSICS")
replace religion = 6 if regexm(RELIGION, "NORSE, WICCAN, STILL EXPLORING/ DECID")
replace religion = 6 if regexm(RELIGION, "NORSE/PAGAN")
replace religion = 6 if regexm(RELIGION, "ORTHODOX DRUID")
replace religion = 6 if regexm(RELIGION, "PAGAN")
replace religion = 6 if regexm(RELIGION, "PAGAN")
replace religion = 6 if regexm(RELIGION, "PAGAN (DRUID, SPECIFICALLY)")
replace religion = 6 if regexm(RELIGION, "PAGAN (FAMILY TRADITION)")
replace religion = 6 if regexm(RELIGION, "PAGAN (WHY IS IT NOT ON THIS LIST?)")
replace religion = 6 if regexm(RELIGION, "PAGAN REFORMIST")
replace religion = 6 if regexm(RELIGION, "PAGAN SPIRITUALITY")
replace religion = 6 if regexm(RELIGION, "PAGAN/ODINISM")
replace religion = 6 if regexm(RELIGION, "PAGAN/SPIRITUAL")
replace religion = 6 if regexm(RELIGION, "PAGAN/WICCAN")
replace religion = 6 if regexm(RELIGION, "PAGAN/WICCAN")
replace religion = 6 if regexm(RELIGION, "PAGANISM")
replace religion = 6 if regexm(RELIGION, "PAGEN")
replace religion = 6 if regexm(RELIGION, "PAGEN")
replace religion = 6 if regexm(RELIGION, "PANTHEISM")
replace religion = 6 if regexm(RELIGION, "PANTHEIST")
replace religion = 6 if regexm(RELIGION, "PEGAN")
replace religion = 6 if regexm(RELIGION, "RASTAFARIAN")
replace religion = 6 if regexm(RELIGION, "RASTAFARIAN")
replace religion = 6 if regexm(RELIGION, "RED ROAD")
replace religion = 6 if regexm(RELIGION, "REINCARNATED PAGAN")
replace religion = 6 if regexm(RELIGION, "SANTERIA")
replace religion = 6 if regexm(RELIGION, "SATAN")
replace religion = 6 if regexm(RELIGION, "SATANIC TEMPLE")
replace religion = 6 if regexm(RELIGION, "SATANIC TEMPLE")
replace religion = 6 if regexm(RELIGION, "SATANIC TEMPLE (TST)")
replace religion = 6 if regexm(RELIGION, "SATANISM")
replace religion = 6 if regexm(RELIGION, "SATANISM")
replace religion = 6 if regexm(RELIGION, "SATANISME")
replace religion = 6 if regexm(RELIGION, "SATANIST")
replace religion = 6 if regexm(RELIGION, "SATANIST")
replace religion = 6 if regexm(RELIGION, "SATANIST / ANARCHISTE")
replace religion = 6 if regexm(RELIGION, "SATANIST BUT FOR REAL")
replace religion = 6 if regexm(RELIGION, "SATANIST- THE SATANIC TEMPLE")
replace religion = 6 if regexm(RELIGION, "SATANISTE")
replace religion = 6 if regexm(RELIGION, "SAULTEAU")
replace religion = 6 if regexm(RELIGION, "SECULAR JEW")
replace religion = 6 if regexm(RELIGION, "SHAMANIC WICCAN")
replace religion = 6 if regexm(RELIGION, "SHAMANISM")
replace religion = 6 if regexm(RELIGION, "SHAMANISM")
replace religion = 6 if regexm(RELIGION, "SHAMANISTIC SPIRITUALITY")
replace religion = 6 if regexm(RELIGION, "SHINTO")
replace religion = 6 if regexm(RELIGION, "SHINTOIST")
replace religion = 6 if regexm(RELIGION, "SIKH")
replace religion = 6 if regexm(RELIGION, "SPIRITUAL INDIGENOUS")
replace religion = 6 if regexm(RELIGION, "SPIRITUALITé AUTOCHTONES")
replace religion = 6 if regexm(RELIGION, "SUFISM")
replace religion = 6 if regexm(RELIGION, "TAO - THE FAITH, NOT RELIGION")
replace religion = 6 if regexm(RELIGION, "TAOISM")
replace religion = 6 if regexm(RELIGION, "TAOISM")
replace religion = 6 if regexm(RELIGION, "TAOIST")
replace religion = 6 if regexm(RELIGION, "TAOIST")
replace religion = 6 if regexm(RELIGION, "THE CREATOR IT'S ABORIGINAL AND SUPPE")
replace religion = 6 if regexm(RELIGION, "THE ONLY TRUE RELIGION OF COURSE THE ")
replace religion = 6 if regexm(RELIGION, "THE SATANIC TEMPLE")
replace religion = 6 if regexm(RELIGION, "THE SATANIC TEMPLE (TST) NON-THEISTIC")
replace religion = 6 if regexm(RELIGION, "TOAISM")
replace religion = 6 if regexm(RELIGION, "TRADITIONAL ABORIGINAL SPIRITUALITY")
replace religion = 6 if regexm(RELIGION, "TRADITIONAL BELIEFS")
replace religion = 6 if regexm(RELIGION, "TRADITIONAL BELIEFS (FIRST NATION) AN")
replace religion = 6 if regexm(RELIGION, "VIKING PAGEN")
replace religion = 6 if regexm(RELIGION, "WICCA")
replace religion = 6 if regexm(RELIGION, "WICCA")
replace religion = 6 if regexm(RELIGION, "WICCAN")
replace religion = 6 if regexm(RELIGION, "WICCAN")
replace religion = 6 if regexm(RELIGION, "WICCAN /PAGAN")
replace religion = 6 if regexm(RELIGION, "WICCAN SPIRITUALITY")
replace religion = 6 if regexm(RELIGION, "WICCAN/ PAGAN")
replace religion = 6 if regexm(RELIGION, "WICCAN/ASATRU")
replace religion = 6 if regexm(RELIGION, "WICCAN/PAGAN")
replace religion = 6 if regexm(RELIGION, "WICCIAN")
replace religion = 6 if regexm(RELIGION, "WITCH")
replace religion = 6 if regexm(RELIGION, "YOGIQUE")
replace religion = 6 if regexm(RELIGION, "ZORASTRIAN")
replace religion = 6 if regexm(RELIGION, "ZOROASTRAIN")
replace religion = 6 if regexm(RELIGION, "ZOROASTRIAN")
replace religion = 6 if regexm(RELIGION, "ZOROASTRIAN")
replace religion = 7 if regexm(RELIGION, "A MIX")
replace religion = 7 if regexm(RELIGION, "ABRAHAMISM")
replace religion = 7 if regexm(RELIGION, "BAPTISE CATHOLIQUE MAIS JE SUIS SPIRI")
replace religion = 7 if regexm(RELIGION, "BELIEVE FROM THE HEART")
replace religion = 7 if regexm(RELIGION, "BELIEVE IN ALL RELIGIONS AND BELIEFS")
replace religion = 7 if regexm(RELIGION, "GENERALLY SPIRITUAL")
replace religion = 7 if regexm(RELIGION, "I AM SPIRITUAL")
replace religion = 7 if regexm(RELIGION, "I AM SPIRITUAL AND BELIEVE IN ONE GOD")
replace religion = 7 if regexm(RELIGION, "I AM SPIRITUAL NOT RELIGIOUS")
replace religion = 7 if regexm(RELIGION, "I AM SPIRITUAL, NOT RELIGIOUS. I DO N")
replace religion = 7 if regexm(RELIGION, "I HAVE DEVELOPED MY OWN SPIRITUALITY")
replace religion = 7 if regexm(RELIGION, "I JUST FEEL LIKE I AM A SPIRITUAL BEI")
replace religion = 7 if regexm(RELIGION, "I'M SPIRITUAL.")
replace religion = 7 if regexm(RELIGION, "I’M SPIRITUAL, NOT RELIGIOUS (I.E., N")
replace religion = 7 if regexm(RELIGION, "IM SPIRITUAL, NOT RELIGIOUS")
replace religion = 7 if regexm(RELIGION, "J'ABORDE PLUT�T UNE APPROCHE SPIRITUE")
replace religion = 7 if regexm(RELIGION, "JUST SPIRITUAL")
replace religion = 7 if regexm(RELIGION, "JUSTE UNE SPIRITUALITé")
replace religion = 7 if regexm(RELIGION, "MORE SPIRITUAL THAN BELONGING TO A SI")
replace religion = 7 if regexm(RELIGION, "MORE SPIRITUAL THEN RELIGIOUS")
replace religion = 7 if regexm(RELIGION, "MYSTICISM/ HOLD NON RELIGIOUS SPIRITU")
replace religion = 7 if regexm(RELIGION, "NO SPECIFIC, IF ANY SPIRITUALIST.")
replace religion = 7 if regexm(RELIGION, "NON DENOMINATIONAL SPIRITUAL")
replace religion = 7 if regexm(RELIGION, "NONDENOMINATIONAL SPIRITUAL WITH BUDD")
replace religion = 7 if regexm(RELIGION, "NONE SPIRITUAL")
replace religion = 7 if regexm(RELIGION, "PERSONAL APPROACH TO SPIRITUALITY")
replace religion = 7 if regexm(RELIGION, "PERSONAL SPIRITUAL CONNECTION")
replace religion = 7 if regexm(RELIGION, "PERSONAL SPIRITUALITY")
replace religion = 7 if regexm(RELIGION, "PERSONALLY SPIRITUAL")
replace religion = 7 if regexm(RELIGION, "RAISED PROTESTANT ; NOW JUST 'SPIRITU")
replace religion = 7 if regexm(RELIGION, "SOMEWHAT SPIRITUAL")
replace religion = 7 if regexm(RELIGION, "SPIRITAL")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL - MIX CHRIST/HINDU/BUDDHISM")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL - NO RELIGION")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL BELIEFS")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL BELIEFS")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL BELIEVE IN A GOD")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL BUT DO NOT BELIEVE IN ORGAN")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL BUT DON'T PRACTICE A RELIGION")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL BUT NO RELIGION")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL BUT NON RELIGIOUS")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL BUT NOT AFFILIATED WITH ORG")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL BUT NOT RELIGIOUS")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL BUT NOT RELIGIOUS")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL DIESM")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL LIGHTWORKER")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL NOT")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL NOT AFFILIATED WITH ANY ORG")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL NOT RELIGIOUS")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL NOT RELIGIOUS")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL NOT RELIGOUS")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL PERSON. NO RELIGION.")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL PRACTICE INSTEAD OF BELIEVI")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL THRU AA")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL WITH NO SPECIFIC AFFILIATION")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL- NOT RELIGIOUS")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL, BUT NO RELIGION PER SE")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL, BUT NOT INSTITUTIONAL")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL, BUT NOT RELIGIOUS")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL, CHRISTIAN BASE")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL, DONT SUBSCRIBE TO AN ORGAN")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL, NO ORGANIZED RELIGION")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL, NO ORGANIZED RELIGION")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL, NON-RELIGIOUS")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL, NOT PART OF ORGANIZED RELI")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL, NOT RELIGIOUS")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL, STILL FIGURING IT OUT")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL, WITH OVER A YEAR OF BIBLE")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL/INTUITIVE")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL/NO RELIGION")
replace religion = 7 if regexm(RELIGION, "SPIRITUAL/NON RELIGOUS")
replace religion = 7 if regexm(RELIGION, "SPIRITUALITé")
replace religion = 7 if regexm(RELIGION, "SPIRITUALITé éCOLOGIQUE")
replace religion = 7 if regexm(RELIGION, "SPIRITUALITY")
replace religion = 7 if regexm(RELIGION, "SPIRITUALITY")
replace religion = 7 if regexm(RELIGION, "SPIRITUALIT�")
replace religion = 7 if regexm(RELIGION, "SPIRITUALLY INCLUSIVE")
replace religion = 7 if regexm(RELIGION, "SPIRITUEL")
replace religion = 7 if regexm(RELIGION, "SPIRITUEL")
replace religion = 7 if regexm(RELIGION, "SPIRITUEL MAIS SANS PLUS")
replace religion = 7 if regexm(RELIGION, "SPIRITUELLE")
replace religion = 7 if regexm(RELIGION, "SPIRITUELLE")
replace religion = 7 if regexm(RELIGION, "SPIRTIAL")
replace religion = 7 if regexm(RELIGION, "SPRITIUAL NOT RELIGIOUS")
replace religion = 7 if regexm(RELIGION, "SPRITUAL - NO MAN MADE RELIGION")
replace religion = 8 if regexm(RELIGION, "A BELIEVER IN GOD")
replace religion = 8 if regexm(RELIGION, "A PERSON OF FAITH WITH NO DENOMINATION")
replace religion = 8 if regexm(RELIGION, "ALIENS")
replace religion = 8 if regexm(RELIGION, "ALIENS")
replace religion = 8 if regexm(RELIGION, "ALL OF THE ABOVE")
replace religion = 8 if regexm(RELIGION, "ALL OF THE ABOVE AND NONE OF THE")
replace religion = 8 if regexm(RELIGION, "ATH� MAIS JE CROIS EN J�SUS")
replace religion = 8 if regexm(RELIGION, "BELIEF IN GOD")
replace religion = 8 if regexm(RELIGION, "BELIEVE IN GOD")
replace religion = 8 if regexm(RELIGION, "BELIEVE IN LOVE")
replace religion = 8 if regexm(RELIGION, "BELIEVE IN THE AFTER LIFE")
replace religion = 8 if regexm(RELIGION, "BELIEVER")
replace religion = 8 if regexm(RELIGION, "BUDDHIST AND CATHOLIC")
replace religion = 8 if regexm(RELIGION, "CAN'T LABEL BELIEFS")
replace religion = 8 if regexm(RELIGION, "CHILD OF GOD")
replace religion = 8 if regexm(RELIGION, "CHRIST PRINCIPLE BELIEVER—RESPECTFUL ")
replace religion = 8 if regexm(RELIGION, "CHRISTIAN / HINDU")
replace religion = 8 if regexm(RELIGION, "COMBINATION NEW AGE CHRISTIAN")
replace religion = 8 if regexm(RELIGION, "CROIRE EN SOI")
replace religion = 8 if regexm(RELIGION, "CROYANT")
replace religion = 8 if regexm(RELIGION, "CROYANT")
replace religion = 8 if regexm(RELIGION, "DEISM")
replace religion = 8 if regexm(RELIGION, "DEISM")
replace religion = 8 if regexm(RELIGION, "DEIST")
replace religion = 8 if regexm(RELIGION, "DEIST")
replace religion = 8 if regexm(RELIGION, "DéISTE")
replace religion = 8 if regexm(RELIGION, "DIEST (BELIEVE IN SUPREME BEING)")
replace religion = 8 if regexm(RELIGION, "DUDISM")
replace religion = 8 if regexm(RELIGION, "EARTH LOVE AND PEACE")
replace religion = 8 if regexm(RELIGION, "ECLECTIC")
replace religion = 8 if regexm(RELIGION, "ECLECTIC")
replace religion = 8 if regexm(RELIGION, "ECLECTIC WICCAN")
replace religion = 8 if regexm(RELIGION, "FAITHFUL AND LOVE EVERYONE")
replace religion = 8 if regexm(RELIGION, "FLEXIBLE")
replace religion = 8 if regexm(RELIGION, "FOLLOWER OF THE WAY")
replace religion = 8 if regexm(RELIGION, "HEATHEN")
replace religion = 8 if regexm(RELIGION, "HUMANIST")
replace religion = 8 if regexm(RELIGION, "HUMANIST")
replace religion = 8 if regexm(RELIGION, "HUMANIST JUDAISM")
replace religion = 8 if regexm(RELIGION, "HUMANIST, SPIRITUALIST")
replace religion = 8 if regexm(RELIGION, "HUMANISTE")
replace religion = 8 if regexm(RELIGION, "HUMANISTIC")
replace religion = 8 if regexm(RELIGION, "HYBRID OF CATHOLIC AND HINDU")
replace religion = 8 if regexm(RELIGION, "I BELEVE IN GOD ONLY")
replace religion = 8 if regexm(RELIGION, "I BELIEVE IN EVERYTHING. WHATEVER SEE")
replace religion = 8 if regexm(RELIGION, "I BELIEVE IN GOD BUT NOT THE BIBLE")
replace religion = 8 if regexm(RELIGION, "I BELIEVE IN GOD BUT NOT THE RELIGION !")
replace religion = 8 if regexm(RELIGION, "I BELIEVE IN GOD PERIOD")
replace religion = 8 if regexm(RELIGION, "I BELIEVE IN GOD, BUT I DON'T HAVE A ")
replace religion = 8 if regexm(RELIGION, "I BELIEVE IN GOD, NOT IN RELIGION. I ")
replace religion = 8 if regexm(RELIGION, "I BELIEVE IN MY OWN THING BUT CANNOT ")
replace religion = 8 if regexm(RELIGION, "I BELIVE THERE IS A GOD")
replace religion = 8 if regexm(RELIGION, "I BELONG TO ALL ❤")
replace religion = 8 if regexm(RELIGION, "I CHOOSE TO BELIEVE IN A GOD, BUT I C")
replace religion = 8 if regexm(RELIGION, "I DON'T ACTIVELY WORSHIP BUT I DO BEL")
replace religion = 8 if regexm(RELIGION, "I DON'T BELIEVE IN A RELGION, BUT BEL")
replace religion = 8 if regexm(RELIGION, "I DON'T HAVE A RELIGION I JUST BELIEV")
replace religion = 8 if regexm(RELIGION, "I DON'T HAVE A RELIGION. I HAVE A BEL")
replace religion = 8 if regexm(RELIGION, "I LIVE BY MY OWN BELIEFS")
replace religion = 8 if regexm(RELIGION, "I LIVE MY LIFE OPEN AND WITHOUT LABEL")
replace religion = 8 if regexm(RELIGION, "I MAINTAIN 2 RELIGIONS ON THIS LIST, ")
replace religion = 8 if regexm(RELIGION, "I RESPECT ALL RELIGIONS")
replace religion = 8 if regexm(RELIGION, "I THINK THAAT THE 12 MOST COMMON RELI")
replace religion = 8 if regexm(RELIGION, "IF IT FEELS WRONG THEN DON'T DO IT")
replace religion = 8 if regexm(RELIGION, "J ACCEPTE TOUTES LES RELIGIONS")
replace religion = 8 if regexm(RELIGION, "J’AI LA FOI SIMPLEMENT")
replace religion = 8 if regexm(RELIGION, "JE CROIS EN DIEU, MAIS AUCUNE RELIGIO")
replace religion = 8 if regexm(RELIGION, "JE CROIS TOUT SIMPLEMENT EN DIEU")
replace religion = 8 if regexm(RELIGION, "JE SUIS LES 10 COMMANDEMENT MAIS CROI")
replace religion = 8 if regexm(RELIGION, "JEDI")
replace religion = 8 if regexm(RELIGION, "JEDI")
replace religion = 8 if regexm(RELIGION, "JIM NABORS GOLLY FRIENDSHIP")
replace religion = 8 if regexm(RELIGION, "JUDEO CHRISTIAN")
replace religion = 8 if regexm(RELIGION, "JUST A BELIEVER")
replace religion = 8 if regexm(RELIGION, "JUST BELIEVE IN WHAT I BELIEVE TO BE ")
replace religion = 8 if regexm(RELIGION, "LA RELIGION DE MON COEUR � NON CELLES")
replace religion = 8 if regexm(RELIGION, "LIBRE-PENSEUR")
replace religion = 8 if regexm(RELIGION, "MA PROPRE RELIGION")
replace religion = 8 if regexm(RELIGION, "MANDALORIAN")
replace religion = 8 if regexm(RELIGION, "MELANGE DE CROYANCES")
replace religion = 8 if regexm(RELIGION, "METAPHYSICAL SPIRITUALITY")
replace religion = 8 if regexm(RELIGION, "MINE")
replace religion = 8 if regexm(RELIGION, "MIX")
replace religion = 8 if regexm(RELIGION, "MIXED")
replace religion = 8 if regexm(RELIGION, "MIXED BELIEFS: DON’T ALIGN WITH A CHU")
replace religion = 8 if regexm(RELIGION, "MONOTHEIST")
replace religion = 8 if regexm(RELIGION, "MORE TO IT THEN THIS")
replace religion = 8 if regexm(RELIGION, "MOTHER EARTH")
replace religion = 8 if regexm(RELIGION, "MOTHER NATURE")
replace religion = 8 if regexm(RELIGION, "MOTHER NATURE")
replace religion = 8 if regexm(RELIGION, "MY FAMILY HAS MULTI RELIGIOUS BACKGRO")
replace religion = 8 if regexm(RELIGION, "MY OWN")
replace religion = 8 if regexm(RELIGION, "MY OWN BELIEF")
replace religion = 8 if regexm(RELIGION, "MY OWN SET OF BELIEFS")
replace religion = 8 if regexm(RELIGION, "NATURE IS MY CHURCH")
replace religion = 8 if regexm(RELIGION, "NIHILIST")
replace religion = 8 if regexm(RELIGION, "OMMIST")
replace religion = 8 if regexm(RELIGION, "OMNIST")
replace religion = 8 if regexm(RELIGION, "OMNIST")
replace religion = 8 if regexm(RELIGION, "OMNITHEIST")
replace religion = 8 if regexm(RELIGION, "OPEN FAITH")
replace religion = 8 if regexm(RELIGION, "OPEN MINDED")
replace religion = 8 if regexm(RELIGION, "OPEN TO WHATEVER THERE BUT DON'T BELI")
replace religion = 8 if regexm(RELIGION, "OPEN-MINDED")
replace religion = 8 if regexm(RELIGION, "OTHER")
replace religion = 8 if regexm(RELIGION, "PANTHEISTIC")
replace religion = 8 if regexm(RELIGION, "PERSONAL")
replace religion = 8 if regexm(RELIGION, "PERSONAL BELIEFS")
replace religion = 8 if regexm(RELIGION, "PLURALIST (NOTE YOU DID NOT INCLUDE B")
replace religion = 8 if regexm(RELIGION, "POLY-RELIGIOUS")
replace religion = 8 if regexm(RELIGION, "POLYTHEISM")
replace religion = 8 if regexm(RELIGION, "POLYTHEIST")
replace religion = 8 if regexm(RELIGION, "PULL IDEAS FROM A NUMBER OF RELIGIONS.")
replace religion = 8 if regexm(RELIGION, "QUANTUM ECTIVIST")
replace religion = 8 if regexm(RELIGION, "RELATIONSHIP WITH GOD")
replace religion = 8 if regexm(RELIGION, "RELIGIOUS")
replace religion = 8 if regexm(RELIGION, "RELIGIOUS WITH NO TIES")
replace religion = 8 if regexm(RELIGION, "SCIENTOLOGIE")
replace religion = 8 if regexm(RELIGION, "SCIENTOLOGIE")
replace religion = 8 if regexm(RELIGION, "SCIENTOLOGIST")
replace religion = 8 if regexm(RELIGION, "SCIENTOLOGIST")
replace religion = 8 if regexm(RELIGION, "SPIRITALIST")
replace religion = 8 if regexm(RELIGION, "SPIRITISME")
replace religion = 8 if regexm(RELIGION, "SPIRITIST")
replace religion = 8 if regexm(RELIGION, "SPIRITIST")
replace religion = 8 if regexm(RELIGION, "SPIRITUALISM")
replace religion = 8 if regexm(RELIGION, "SPIRITUALISM")
replace religion = 8 if regexm(RELIGION, "SPIRITUALIST")
replace religion = 8 if regexm(RELIGION, "SPIRITUALIST")
replace religion = 8 if regexm(RELIGION, "SPIRITUALISTIC")
replace religion = 8 if regexm(RELIGION, "SPIRITULISM")
replace religion = 8 if regexm(RELIGION, "SUN WORSHIP")
replace religion = 8 if regexm(RELIGION, "SUN WORSHIPER")
replace religion = 8 if regexm(RELIGION, "SUPREME HIGHER POWER")
replace religion = 8 if regexm(RELIGION, "TENRIKYO")
replace religion = 8 if regexm(RELIGION, "THE UNIVERSE IS WHAT I WOULD CALL GOD")
replace religion = 8 if regexm(RELIGION, "THE WHEEL")
replace religion = 8 if regexm(RELIGION, "THE WORLD IS MY GOD")
replace religion = 8 if regexm(RELIGION, "THELEMITE")
replace religion = 8 if regexm(RELIGION, "THELMA")
replace religion = 8 if regexm(RELIGION, "THELMIC")
replace religion = 8 if regexm(RELIGION, "TOLLEAN PANTHEIST WITH SPINOZAN JUDEO")
replace religion = 8 if regexm(RELIGION, "TOO COMPLICATED")
replace religion = 8 if regexm(RELIGION, "TREAT OTHERS THE WAY YOU WANT TO BE T")
replace religion = 8 if regexm(RELIGION, "UNIVERSAL")
replace religion = 8 if regexm(RELIGION, "UNIVERSAL RELIGIOUS HUMANISM")
replace religion = 8 if regexm(RELIGION, "WESLEYAN + BUDDHIST")

replace religion = . if regexm(RELIGION, "ACADEMIC")
replace religion = . if regexm(RELIGION, "ARE YOU KIDDING ME?")
replace religion = . if regexm(RELIGION, "ASIAN")
replace religion = . if regexm(RELIGION, "AWARENESS")
replace religion = . if regexm(RELIGION, "BBBBBBBBBBBBBBBB")
replace religion = . if regexm(RELIGION, "CANADIAN")
replace religion = . if regexm(RELIGION, "CANADIAN")
replace religion = . if regexm(RELIGION, "CANADIENS DE MONTRéAL")
replace religion = . if regexm(RELIGION, "CHINESE")
replace religion = . if regexm(RELIGION, "CHINESE")
replace religion = . if regexm(RELIGION, "CHRISTIAN IS A RELIGION, ANGLICAN IS ")
replace religion = . if regexm(RELIGION, "ERREUR DANS LA QUESTION PRéCéDENTE, P")
replace religion = . if regexm(RELIGION, "FREE AGENT")
replace religion = . if regexm(RELIGION, "GIA")
replace religion = . if regexm(RELIGION, "GREEN")
replace religion = . if regexm(RELIGION, "GUYNESE CANADIAN")
replace religion = . if regexm(RELIGION, "HOCKEY")
replace religion = . if regexm(RELIGION, "HONESTY")
replace religion = . if regexm(RELIGION, "HUMAN")
replace religion = . if regexm(RELIGION, "I AM")
replace religion = . if regexm(RELIGION, "I AM MY OWN MASTER")
replace religion = . if regexm(RELIGION, "I D E S")
replace religion = . if regexm(RELIGION, "IMMOBILIER")
replace religion = . if regexm(RELIGION, "INC")
replace religion = . if regexm(RELIGION, "INDIVIUA; SECTS ARE NOY A RELIGION. C")
replace religion = . if regexm(RELIGION, "JIU OOIP")
replace religion = . if regexm(RELIGION, "JUGGALO")
replace religion = . if regexm(RELIGION, "KG1ST")
replace religion = . if regexm(RELIGION, "KNOWLEDGE")
replace religion = . if regexm(RELIGION, "LOOKING")
replace religion = . if regexm(RELIGION, "LOST")
replace religion = . if regexm(RELIGION, "MEMBER OF THE HUMAN RACE")
replace religion = . if regexm(RELIGION, "MEXICAN LATINO")
replace religion = . if regexm(RELIGION, "MODERN CONTEMPORARY")
replace religion = . if regexm(RELIGION, "MY BELIEF IN GOD SHOULD HAVE NO BEARI")
replace religion = . if regexm(RELIGION, "MYSELF")
replace religion = . if regexm(RELIGION, "MYSELF")
replace religion = . if regexm(RELIGION, "NA")
replace religion = . if regexm(RELIGION, "NIP")
replace religion = . if regexm(RELIGION, "NONE OF THE ABOVE")
replace religion = . if regexm(RELIGION, "NONE OF YOUR BUSINESS")
replace religion = . if regexm(RELIGION, "PENNYCOST")
replace religion = . if regexm(RELIGION, "QUéBéCOIS")
replace religion = . if regexm(RELIGION, "QUéBéCOISE")
replace religion = . if regexm(RELIGION, "REALIST")
replace religion = . if regexm(RELIGION, "TAIWAN")
replace religion = . if regexm(RELIGION, "TAMOULE")
replace religion = . if regexm(RELIGION, "UNITY")
replace religion = . if regexm(RELIGION, "VER DE TERRE")
replace religion = . if regexm(RELIGION, "WHY DOES IT MATTER WHAT I BELIEVE?")

** LABEL VALUES AND VARIABLE
label define religions 0 "Atheist/Agnostic/No Religion" ///
		       1 "Roman Catholic" ///
		       2 "Mainline Protestant (Big Five)" ///
		       3 "Evangelical/Conservative Christian" ///
		       4 "Eastern Orthodox" ///
		       5 "Other Christian" ///
		       6 "Non-Christian Religions" ///
		       7 "Spiritual, Not Religious" ///
		       8 "Other"
label values religion religions
label variable religion "Religion (9 Categories)"

****************************
*** PROVINCE / TERRITORY ***
****************************

*** RECODING: PROVINCE / TERRITORY
gen pt = .
replace pt = 1 if cps21_province == 5
replace pt = 2 if cps21_province == 7
replace pt = 3 if cps21_province == 10
replace pt = 4 if cps21_province == 4
replace pt = 5 if cps21_province == 11
replace pt = 6 if cps21_province == 9
replace pt = 7 if cps21_province == 3
replace pt = 8 if cps21_province == 12
replace pt = 9 if cps21_province == 1
replace pt = 10 if cps21_province == 2
replace pt = 11 if cps21_province == 13
replace pt = 12 if cps21_province == 6
replace pt = 13 if cps21_province == 8 

label define provinces 1 "NL" 2 "NS" 3 "PE" 4 "NB" 5 "QC" 6 "ON" 7 "MB" 8 "SK" 9 "AB" 10 "BC" 11 "YT" 12 "NT" 13 "NV"
label values pt provinces
label variable pt "Province or Territory"

*** REGION
gen region = 1 if pt < 5
replace region = 2 if pt == 5
replace region = 3 if pt == 6
replace region = 4 if pt > 6 & pt < 11
replace region = 5 if pt > 10

label define regions 1 "Atlantic" 2 "Quebec" 3 "Ontario" 4 "West" 5 "Territories"
label values region regions
label variable region "Region"

****************************
*** PARTY IDENTIFICATION ***
****************************

tab cps21_fed_id
list cps21_fed_id_6_TEXT if cps21_fed_id_6_TEXT ~= "-99"

gen other_pid = upper(cps21_fed_id_6_TEXT) if cps21_fed_id_6_TEXT ~= "-99"

gen partyid = .
replace partyid = cps21_fed_id if cps21_fed_id < 6
replace partyid = 6 if regexm(other_pid, "PPC") | regexm(other_pid, "PEOPLE")
replace partyid = 7 if partyid == . & cps21_fed_id == 6
replace partyid = 8 if cps21_fed_id == 7

label define parties 1 "Lib." 2 "Con." 3 "NDP" 4 "BQ" 5 "Green" 6 "PPC" 7 "Other" 8 "None"
label values partyid parties

**********************
*** MARITAL STATUS ***
**********************

gen married = .
replace married = 0 if cps21_marital > 1 & cps21_marital < 7
replace married = 1 if cps21_marital == 1

************************
*** CHILDREN AT HOME ***
************************

gen children = .
replace children = 0 if cps21_children == 1
replace children = 1 if cps21_children > 1 & cps21_children < 7

******************************************
*** OTHER GENDER GAP OUTCOME VARIABLES ***
*** CAMPAIGN PERIOD STUDY ****************
******************************************

**********************
*** VOTE INTENTION ***
**********************

tab cps21_votechoice
gen voteintention = cps21_votechoice if cps21_votechoice < 9
replace voteintention = . if voteintention == 7

label define parties2 1 "Liberal" 2 "Conservative" 3 "NDP" 4 "BQ" 5 "Green" 6 "Others" 8 "None"
label values voteintention parties2

tab voteintention, gen(vote_)

*** ATTITUDES
*0 = Right
*1 = Left

* disagree coded as right-wing
gen fptp = (cps21_pos_fptp - 1) / 4 if cps21_pos_fptp < 6
* disagree coded as right-wing
gen assisted_dying = (cps21_pos_life - 1) / 4 if cps21_pos_life < 6
* agree coded as right-wing
gen cannabis = ((cps21_pos_cannabis * -1) + 5) / 4 if cps21_pos_cannabis < 6
* disagree coded as right-wing
gen carbon_tax = (cps21_pos_carbon - 1) / 4 if cps21_pos_carbon < 6
* agree coded as right-wing
gen pipelines = ((cps21_pos_energy * -1) + 5) / 4 if cps21_pos_energy < 6
* disagree coded as right-wing
gen environmental_regulation = (cps21_pos_envreg - 1) / 4 if cps21_pos_envreg < 6
* agree coded as right-wing
gen jobs_vs_environment = ((cps21_pos_jobs * -1) + 5) / 4 if cps21_pos_jobs < 6
* disagree coded as right-wing
gen corporate_subsidies = (cps21_pos_subsid - 1) / 4 if cps21_pos_subsid < 6
* agree coded as right-wing
gen free_trade = ((cps21_pos_trade * -1) + 5) / 4 if cps21_pos_trade < 6
* more = 1 / fewer = 2 / about the same = 3
gen immigration = 1 if cps21_imm == 1
replace immigration = 0 if cps21_imm == 2
replace immigration = 0.5 if cps21_imm == 3
* more = 1 / fewer = 2 / about the same = 3
gen refugees = 1 if cps21_refugees == 1
replace refugees = 0 if cps21_refugees == 2
replace refugees = 0.5 if cps21_refugees == 3

*** EFFICACY
** GOVERNMENT CONFUSING
tab cps21_govt_confusing
tab cps21_govt_confusing, nol

gen confusing = (-1 * (cps21_govt_confusing - 4))/3 if cps21_govt_confusing < 5

** NO SAY
tab cps21_govt_say
tab cps21_govt_say, nol
gen say = (-1 * (cps21_govt_say - 4))/3 if cps21_govt_say < 5

** EFFICACY SCALE
gen efficacy = (confusing + say) / 2
corr say confusing efficacy

*** DEMOCRATIC SATSIFACTION
tab cps21_demsat
tab cps21_demsat, nol

gen satisfaction = (-1 * (cps21_demsat - 4))/3 if cps21_demsat < 5


*************************************
*** POST-ELECTION STUDY VARIABLES ***
*** USE WITH CAUTION ****************
*** AND MODEL ATTRITION FROM CPS ****
*************************************

*********************
*** VOTER TURNOUT ***
*********************

gen turnout = 0 if pes21_turnout2021 ~= .
replace turnout = 1 if pes21_turnout2021 == 1

*****************
*** 2021 VOTE ***
*****************

gen votechoice2021 = pes21_votechoice2021 if pes21_votechoice2021 < 7
replace votechoice2021 = 6 if votechoice2021 == 7

label values votechoice2021 parties

**********************
*** COMMUNITY SIZE ***
**********************

tab pes21_rural_urban
*** CHECK LABELS FROM PES QUESTIONNAIRE

gen community_size = .
replace community_size = pes21_rural_urban if pes21_rural_urban < 6

label define communities 1 "Rural/village (<1K)" ///
			 2 "Small town (1-15K)" ///
			 3 "Mid-size town (15K-50K)" ///
			 4 "Suburb" ///
			 5 "Large town or city (>50K)"

**********************************************
*** FEELING THERMOMETER: GAYS AND LESBIANS ***
**********************************************

gen thermometer = .
replace thermometer = pes21_groups1_2 if pes21_groups1_2 > -99 & pes21_groups1_2 ~= .

label variable thermometer "Feeling Thermometer: Gays and Lesbians (0-100)"

***************************************************
*** HOW MUCH SHOULD BE DONE?: GAYS AND LESBIANS ***
***************************************************

tab pes21_donegl
gen moredone = pes21_donegl
** TAKE A LOOK AT WHO ANSWERS "6" (DON'T KNOW)

label variable moredone "How Much Should Be Done for Gays and Lesbians? (0-1)"

***********************
*** ISSUE ATTITUDES ***
***********************

*** PAYING FOR FASTER PRIVATE HEALTH CARE
gen private_health_care = .
replace private_health_care = ((((pes21_paymed * -1) + 1) / 4) + 1) if pes21_paymed < 6
tab pes21_paymed private_health_care

*** SENATE ABOLITION
gen senate_abolition = .
replace senate_abolition = ((pes21_senate - 1) / 4) if pes21_senate < 6
tab pes21_senate senate_abolition

*** HATE SPEECH
gen hate_speech = .
replace hate_speech = ((pes21_hatespeech - 1) / 4) if pes21_hatespeech < 6
tab pes21_hatespeech hate_speech

*** JOBS VS. ENVIORNMENT
gen jobs_vs_environment_pes = .
replace jobs_vs_environment_pes = ((((pes21_envirojob * -1) + 1) / 4) + 1) if pes21_envirojob < 6
tab pes21_envirojob jobs_vs_environment_pes

*** "FAMILY VALUES"
gen family_values = .
replace family_values = ((((pes21_famvalues * -1) + 1) / 4) + 1) if pes21_famvalues < 6
tab pes21_famvalues family_values

*** BILINGUALISM
gen bilingualism = .
replace bilingualism = ((((pes21_bilingualism * -1) + 1) / 4) + 1) if pes21_bilingualism < 6
tab pes21_bilingualism bilingualism

*** EQUAL RIGHTS
gen equal_rights = .
replace equal_rights = ((((pes21_equalrights * -1) + 1) / 4) + 1) if pes21_equalrights < 6
tab pes21_equalrights equal_rights

*** IMMIGRANT INTEGRATION
gen immigrant_integration = .
replace immigrant_integration = ((((pes21_fitin * -1) + 1) / 4) + 1) if pes21_fitin < 6
tab pes21_fitin immigrant_integration

*** IMMIGRANTS AND JOBS
gen immigrant_jobs = .
replace immigrant_jobs = ((((pes21_immigjobs * -1) + 1) / 4) + 1) if pes21_immigjobs < 6
tab pes21_immigjobs immigrant_jobs

*** TIES TO US
gen ties_US = .
replace ties_US = ((pes21_tieus - 1) / 4) if pes21_tieus < 6
tab pes21_tieus ties_US

*** TIES TO CHINA
gen ties_China = .
replace ties_China = ((((pes21_tiechina * -1) + 1) / 4) + 1) if pes21_tiechina < 6
tab pes21_tiechina ties_China

*** WOMEN'S REPRESENTATION
gen women_representation = .
replace women_representation = ((pes21_womenparl - 1) / 4) if pes21_womenparl < 6
tab pes21_womenparl women_representation

*** ABORTION
gen abortion = .
replace abortion = ((pes21_abort2 - 1) / 2) if pes21_abort2 < 4
tab pes21_abort2 abortion

*** CONVERSION THERAPY
gen conversion_therapy = .
replace conversion_therapy = pes21_conversion_the - 1 if pes21_conversion_the < 3
tab pes21_conversion_the conversion_therapy

*** INTERNATIONAL TRADE
gen international_trade = .
replace international_trade = ((((pes21_trade * -1) + 1) / 4) + 1) if pes21_trade < 6
tab pes21_trade international_trade

*** GOVERNMENT INTERVENTION
gen government_intervention = .
replace government_intervention = ((((pes21_privjobs * -1) + 1) / 4) + 1) if pes21_privjobs < 6
tab pes21_privjobs government_intervention

*** INCOME INEQUALITY
gen income_inequality = .
replace income_inequality = ((((pes21_inequal * -1) + 1) / 4) + 1) if pes21_inequal < 6
tab pes21_inequal income_inequality

*** GAP BETWEEN RICH AND POOR
gen wealth_gap = .
replace wealth_gap = ((((pes21_gap * -1) + 1) / 4) + 1) if pes21_gap < 6
tab pes21_gap wealth_gap

************************************
*** EXPORT DATA AS ANALYSIS FILE ***
************************************

preserve
keep cps21_weight_general_all-wealth_gap
gen id = _n

order id, first
order cps21_weight_general_all-pes21_weight_general_restricted, last

save "GenderGapAnalysis.dta", replace
restore

*********************************
*** CHECK DATA QUALITY ISSUES ***
*********************************

** CROSS-TABULATIONS WITH GENDER QUALITY ISSUES
tab genderid cps21_duplicates_pid_flag, row // no sign
tab genderid cps21_duplicate_ip_demo_flag, row // no sign
tab genderid cps21_inattentive, row // few signs
tab genderid pes21_speeder_low_quality, row // no sign
tab genderid pes21_duplicates_pid_flag, row // no sign
tab genderid pes21_inattentive, row // few signs

*** DATA QUALITY GRAPHS FOR SUPPLEMENTARY MATERIALS ***
** CAMPAIGN PERIOD WAVE
ttest cps21_time if cps21_time < 61, by(enby)

twoway (histogram cps21_time if cps21_time < 61, freq bcolor(gs14) width(1)) (histogram cps21_time if genderid == 3 & cps21_time< 61, freq bcolor(black) width(1)), xline(19.21, lcolor(black) lpattern(shortdash)) xline(23.21, lcolor(gs14) lpattern(shortdash)) legend(label(1 "All Resondents") label(2 "Nonbinary Respondents"))
graph export "${here}CPS_ResponseTime_NB.png", height(1800) width(2400) replace

** POST-ELECTION WAVE
ttest pes21_time if pes21_time < 61, by(enby)

twoway (histogram pes21_time if pes21_time < 61, freq bcolor(gs14) width(1)) (histogram pes21_time if genderid == 3 & pes21_time < 61, freq bcolor(black) width(1)), xline(18.30, lcolor(black) lpattern(shortdash)) xline(22.49, lcolor(gs14) lpattern(shortdash)) legend(label(1 "All Resondents") label(2 "Nonbinary Respondents"))
graph export "${here}PES_ResponseTime_NB.png", height(1800) width(2400) replace

** DROP LOW-QUALITY RESPONDENTS
drop if cps21_duplicates_pid_flag == 1 | ///
		cps21_duplicate_ip_demo_flag == 1 | ///
		cps21_inattentive == 1 | ///
		pes21_speeder_low_quality == 1 | ///
		pes21_duplicates_pid_flag == 1 | ///
		pes21_inattentive == 1

save "${here}GenderGapHighQuality.dta", replace